title: Laravel 5.2 - filtering on a custom attribute and then paginating
body: <p>So I know how to paginate using <code>paginate()</code> and I know how to filter based on an <a href="https://laravel.com/docs/5.2/eloquent-mutators#accessors-and-mutators" rel="nofollow">Accessor</a> (a <code>where()</code> on the collection). However, paginate takes in a query builder and where() on a collection returns a collection. </p>
  
  <p>So if I want to get a bunch of items / filter by a custom attribute and then paginate the result set....how do i do that??</p>
  
  <p>Accessor:</p>
  
  <pre><code>public function getRequiredToReportAttribute()
  {
    // return boolean based off of complicated business logic
  }
  </code></pre>
  
  <p>index method:</p>
  
  <pre><code>public function index()
  {
      //what im doing (redacted)
      $employers = (new App\Employers')-&gt;paginate($this-&gt;perPage);
  
      // what I would like to be doing
      $employers = (new App\Employers)-&gt;where('required_to_report', '=', true)-&gt;paginate($this-&gt;perPage);
  
  
      return $this-&gt;sendResponse($employers);
  }
  </code></pre>