Skip to content

WARNING You're browsing the documentation for an old version of LARAVEL-DATATABLES. Consider upgrading your project to laravel-datatables 11.0.

Sending parameter to DataTable class

You can send a parameter from controller to dataTable class using with api.


Route::get('datatable/{id}', function(UsersDataTable $dataTable, $id){
return $dataTable->with('id', $id)
'key2' => 'value2',
'key3' => 'value3',

You can then get the variable as a local property of the class.

class UsersDataTable {
public function query() {
return User::where('id', $this->id);