title: Unable to assign variable value in model constructor
body: <p>I am playing with Laravel models and I need one to return a value that is not in the db table but it comes by running a model method. This method runs a query that groups and count grouped results.</p>
  
  <p>The model method works just fine but I don't seem to be able to pre-fill the $quantity variable within the constructor with something different than 0.</p>
  
  <p>So this is an excerpt of the model:</p>
  
  <pre><code>public $quantity;
  
  function __construct($attributes = array(), $exists = false) {
      parent::__construct($attributes, $exists);
      $this-&gt;quantity = $this-&gt;quantity();
  }
  
  public function quantity()
  {
      $query = DB::table('carts_shopping')
              -&gt;select('cart_id', DB::raw('COUNT(*) AS quantity'))
              -&gt;where('cart_id',$this-&gt;cart_id)
              -&gt;groupBy('cart_id')
              -&gt;first();
      return ($query) ? $query-&gt;quantity : 0;
  }
  </code></pre>
  
  <p>While this is how I am trying to retrieve the results from controller:</p>
  
  <pre><code>$cartitems = Auth::user()-&gt;cartshopping;
  
  foreach ($cartitems as $cartitem)
  {
      echo $cartitem-&gt;name;
      echo $cartitem-&gt;quantity;
  }
  </code></pre>
  
  <p>As you may guess 'cartshopping' comes from the user model being related with the model excerpt I pasted.</p>
  
  <p>I also noticed that quantity() method gets called and it returns 0 all the time as if $this->cart_id was empty and, changing $this-cart_id with a real value the query itself doesn't even get executed.</p>
  
  <p>Thanks a lot for any suggestion you guys can share.</p>