title: Using Query Scope to filter results within Laravel Blade template
body: <p>I'm using query scope within my controllers in some places but now i'm trying to filter down some results within my blade template.  My model has a location which has orders. I pass the location to the blade template and then use the following:</p>
  
  <pre><code>@foreach( $location-&gt;orders-&gt;datesearch('delivered_at','2015-10-01','2015-10-15') as $order )
      {{ $order-&gt;order_number }}&lt;br /&gt;
  @endforeach
  </code></pre>
  
  <p>And here's an excerpt from my Order Model</p>
  
  <pre><code>class Order extends Model {
  
      public function location()
      {
          return $this-&gt;belongsTo('App\Location', 'location_id');
      }
  
     public function scopeDatesearch($query,$datesearch,$search_date_start,$search_date_end)
         {
             return $query-&gt;whereBetween($datesearch, [$search_date_start, $search_date_end])-&gt;get();
         }
  }
  </code></pre>
  
  <p>Location hasMany Orders as well. </p>
  
  <p>The error I'm getting is:</p>
  
  <pre><code>FatalErrorException in 56b3a0ff15f6ddc28458248fd0728a27 line 5:
  Call to undefined method Illuminate\Database\Eloquent\Collection::datesearch()
  </code></pre>
  
  <p>I did find <a href="https://stackoverflow.com/questions/32700283/use-queryscope-in-blade-template">this similar posting</a> which seems to indicate what I'm doing should work.</p>