title: Use an append attribute in a eloquent condition
body: <p>this is my situation of my laravel project:</p>
  
  <ul>
  <li>I have 3 models: Travel, Activity and Expense.</li>
  <li>One Travel has many Activities and many Expenses.</li>
  <li>Model attributes:
  
  <ul>
  <li>Travel: id, title, desc, date, location</li>
  <li>Activity: id, travel_id, title, desc, date, prize</li>
  <li>Expense: id, travel_id, title, desc, prize</li>
  </ul></li>
  <li>The Travel model has an append attribute called 'total_prize', that is the sum of all Expenses and Activities that it has.</li>
  </ul>
  
  <p>So far so good. My problem is when I try to apply the filter 'available_amount &lt;= total_prize' to Travel's list.</p>
  
  <p>How can I use the append attribute 'total_prize' for get all travels less than the amount_available?</p>
  
  <ul>
  <li>amount_available is a post request variable.</li>
  </ul>
  
  <p>This is the accessor for total_prize attribute:</p>
  
  <pre><code> public function getTotalPrizeAttribute()
      {
          return (float) $this-&gt;activities-&gt;sum('prize') + $this-&gt;expenses-&gt;sum('prize');
      }
  </code></pre>
  
  <p>I want to do something like this:</p>
  
  <pre><code>Travel::where('total_prize', '&lt;=', 'amount_available')-&gt;get();
  </code></pre>