title: Laravel yajra Datatable : How to send parameters to DataTable Service Class for custom query?
body: <p>How do I pass parameters like ( <code>res_id</code>, <code>resname</code> etc ) to the <code>DataTable Service Class</code> (<code>RestaurantDataTable</code>) for Custom DB queries like ( get only restaurant where <code>id = x</code>, or <code>resname = xxx</code> etc)?</p>
  
  <p>RestaurantController:</p>
  
  <pre><code>use App\DataTables\restaurantDataTable;
  
      class restaurantController extends AppBaseController
      {
         public function index(restaurantDataTable $restaurantDataTable)
         {
  
             return $restaurantDataTable-&gt;render('restaurant.index');
  
         }
      }
  </code></pre>
  
  <p>restaurantDataTable:</p>
  
  <pre><code>class restaurantDataTable extends DataTable
  {
  
      /**
       * @return \Illuminate\Http\JsonResponse
       */
      public function ajax()
      {
  
          return $this-&gt;datatables
              -&gt;eloquent($this-&gt;query())
              -&gt;addColumn('action', 'restaurant.datatables_actions')
              -&gt;make(true);
      }
  
      /**
       * Get the query object to be processed by datatables.
       *
       * @return \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder
       */
      public function query()
      {
  
          $restaurants = restaurant::query();
  
          return $this-&gt;applyScopes($restaurants);
  
  
  
      }
  
      /**
       * Optional method if you want to use html builder.
       *
       * @return \Yajra\Datatables\Html\Builder
       */
      public function html()
      {
          return $this-&gt;builder()
              -&gt;columns($this-&gt;getColumns())
              -&gt;addAction(['width' =&gt; '10%'])
              -&gt;ajax('')
              -&gt;parameters([
                  'dom' =&gt; 'Blfrtip',
                  'scrollX' =&gt; false,
                  'buttons' =&gt; [
                      'print',
                      'reset',
                      'reload',
                      [
                           'extend'  =&gt; 'collection',
                           'text'    =&gt; '&lt;i class="fa fa-download"&gt;&lt;/i&gt; Export',
                           'buttons' =&gt; [
                               'csv',
                               'excel',
                               'pdf',
                           ],
                      ],
                      'colvis'
                  ]
              ]);
      }
  
      /**
       * Get columns.
       *
       * @return array
       */
      private function getColumns()
      {
          return [
              'res_name' =&gt; ['name' =&gt; 'res_name', 'data' =&gt; 'res_name'],
              'res_address' =&gt; ['name' =&gt; 'res_address', 'data' =&gt; 'res_address'],
              'res_state' =&gt; ['name' =&gt; 'res_state', 'data' =&gt; 'res_state'],
              'res_location' =&gt; ['name' =&gt; 'res_location', 'data' =&gt; 'res_location'],
              'res_area' =&gt; ['name' =&gt; 'res_area', 'data' =&gt; 'res_area']
          ];
      }
  
      /**
       * Get filename for export.
       *
       * @return string
       */
      protected function filename()
      {
          return 'restaurant';
      }
  }
  </code></pre>
  
  <p>Table.blade.php:</p>
  
  <pre><code>@section('css')
      @include('layouts.datatables_css')
  @endsection
  
  {!! $dataTable-&gt;table(['width' =&gt; '100%']) !!}
  
  
  @section('scripts')
      @include('layouts.datatables_js')
      {!! $dataTable-&gt;scripts() !!}
  @endsection
  </code></pre>
  
  <p>Do I need to customize the functions in <code>UsersDataTable</code> Class like <code>public function custom_query($param) {}</code> or <code>public function custom_ajax($param) {}</code>?</p>