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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With