title: Laravel Yajra Datatable Server Side with pagination problems
body: <p>I'm newby on Laravel and I'm trying to use <a href="https://github.com/yajra/laravel-datatables" rel="noreferrer">Yajra Datatable</a> Plugin with server side funtionality. The plugin works well with a small amount of records, but I have a large amount of about 100000 record. </p>
  
  <p>To speed up the process in my controller I limit the query's result with take(10) and I use another query to count the total results. So far everything is fine.</p>
  
  <p>The problem is how to manage research. In addition to the main research field, i used also the <a href="https://datatables.net/examples/api/multi_filter.html" rel="noreferrer">individual column searching</a> but I don't know how to return the correct numbers of record to manage the pagination with the individual searching filter. </p>
  
  <p>I think that the individuals search keys are in <code>$columns = $request-&gt;get('columns');</code> but I don't know how to manage count's query.</p>
  
  <p>Thanks you for your precious advice.</p>
  
  <p>HTML View Code:</p>
  
  <pre><code>&lt;table id="oTable"&gt;
     &lt;thead&gt;
        &lt;tr&gt;
           &lt;th&gt;Action&lt;/th&gt;
           &lt;th&gt;Brand&lt;/th&gt;
           &lt;th&gt;Code&lt;/th&gt;
           &lt;th&gt;Description&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
           &lt;th class="no_search"&gt;&lt;/th&gt;
           &lt;th&gt;&lt;/th&gt;
           &lt;th&gt;&lt;/th&gt;
           &lt;th&gt;&lt;/th&gt;
        &lt;/tr&gt;
     &lt;/thead&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>Jquery Code:</p>
  
  <pre><code>$('#oTable').DataTable({
      dom: 'lfrtip',
      "processing": true,
      "serverSide": true,
      "ajax": '{!! url('getRecords') !!}',
      "columns": [
        {data: 'items.id', name: 'items_id'},
        {data: 'brands.description', name: 'brands_description'},
        {data: 'items.code', name: 'items_code'},
        {data: 'items.description', name: 'items_description'}
      ],
      columnDefs: [
        {targets: 'no_sort', orderable: false}
      ],
      initComplete: function () {
  
        this.api().columns().every(function () {
          var column = this;
          var columnClass = column.header().className;
          if (columnClass.indexOf('no_search') != false) {
            var input = document.createElement("input");
            $(input).addClass('form-control');
            $(input).appendTo($(column.header()).empty())
            .on('change', function () {
              column.search($(this).val(), false, false, true).draw();
            });
          }
        });
      }
    });
  </code></pre>
  
  <p>Controller's method:</p>
  
  <pre><code>public function getRecords(Request $request) {
  
        $search = $request-&gt;input('search.value');
        $columns = $request-&gt;get('columns');
  
        $count_total = \DB::table('items')
                          -&gt;join('brands', 'item.brand', '=', 'brands.code')
                          -&gt;count();
  
        $count_filter = \DB::table('items')
                          -&gt;join('brands', 'items.brand', '=', 'brands.code')
                          -&gt;where(   'brands.description' , 'LIKE' , '%'.$search.'%')
                          -&gt;orWhere( 'items.description' , 'LIKE' , '%'.$search.'%')
                          -&gt;orWhere( 'items.code' , 'LIKE' , '%'.$search.'%')
                          -&gt;count();
  
        $items= \DB::table('items')
          -&gt;join('brands', 'items.brand', '=', 'brands.code')
          -&gt;select(
              'items.id as items_id',
              'items.code as items_code',
              'items.description as items_description',
              'brands.description as brands_description'
          ) -&gt; take(10);
  
          return Datatables::of($items)          
            -&gt;with([
              "recordsTotal" =&gt; $count_total,
              "recordsFiltered" =&gt; $count_filter,
            ])
            -&gt;rawColumns(['items_id','brands_description'])
            -&gt;make(true);
      }
  </code></pre>