4

I have installed yajra/laravel-datatables-oracle package for supporting serverside datatables in laravel 5.1 with mongodb 3.3 as database. I have connected laravel 5.1 with mongodb through jenssegers-mongodb package. It is connecting successfully , but datatable is not working properly.

js

$('#vendorDatatable').DataTable({
                "processing": true,
                "serverSide": true,
                "order": [[ 0, "desc" ]],
                "ajax": baseUrl+'/vendors/data',
                "columns": [
                    {"data": 'branch', "name": 'branch'}
            ],
            });

Route

Route::get('vendors/data','VendorsController@getList');

VendorsController

public function getList(){
       $vendors = Vendors::select(['branch']);

        return Datatables::of($vendors)->make();

    }

Error while accessing ../vendors/data

FatalErrorException in Builder.php line 1309: Call to a member function compileSelect() on a non-object
Haseena P A
  • 16,858
  • 4
  • 18
  • 35

1 Answers1

4

Just add ->get() to the query in controller

public function getList(){
   $vendors = Vendors::select(['branch'])->get();
   return Datatables::of($vendors)->make();
}

This is required to get the result data in proper format.

Joel James
  • 1,315
  • 1
  • 20
  • 37