title: Add a custom attribute to a Laravel / Eloquent model on load?
body: <p>I'd like to be able to add a custom attribute/property to an Laravel/Eloquent model when it is loaded, similar to how that might be achieved with <a href="http://redbeanphp.com/manual/models_and_fuse">RedBean's</a> <code>$model-&gt;open()</code> method.</p>
  
  <p>For instance, at the moment, in my controller I have:</p>
  
  <pre><code>public function index()
  {
      $sessions = EventSession::all();
      foreach ($sessions as $i =&gt; $session) {
          $sessions[$i]-&gt;available = $session-&gt;getAvailability();
      }
      return $sessions;
  }
  </code></pre>
  
  <p>It would be nice to be able to omit the loop and have the 'available' attribute already set and populated.</p>
  
  <p>I've tried using some of the model events described in the documentation to attach this property when the object loads, but without success so far.</p>
  
  <p><em>Notes:</em></p>
  
  <ul>
  <li>'available' is not a field in the underlying table.</li>
  <li><code>$sessions</code> is being returned as a JSON object as part of an API, and therefore calling something like <code>$session-&gt;available()</code> in a template isn't an option</li>
  </ul>