title: How can I search in pivot table if using custom filter in yajra-laravel-datatable package (laravel 5.1)
body: <h1>Schema</h1>
  
  <p><strong>Utility_provider_plan</strong></p>
  
  <pre><code>id, plan_name, etc.
  </code></pre>
  
  <p><strong>Energy_provider_plan</strong></p>
  
  <pre><code>id, name, etc.
  </code></pre>
  
  <p><strong>Energy_plan_utility_plans (pivot table)</strong></p>
  
  <pre><code>id, energy_provider_plan_id, utility_provider_plan_id
  </code></pre>
  
  <p>So, I want to filter all result with 'utility_provider_plan_id' column (pivot table).</p>
  
  <p>Here is my code by using yajra-laravel-datatable,</p>
  
  <pre><code>return Datatables::of($energyProviderPlans)
  -&gt;filter(function ($query) use ($request) {
      if ($request-&gt;has('utility_provider_plan_id')) {
          return $query-&gt;utility_provider_plan-&gt;where('energy_plan_utility_plans.utility_provider_plan_id', '=', 1);
      }
  })
  -&gt;make(true);
  </code></pre>