Skip to content

WARNING You're browsing the documentation for an upcoming version of Laravel DataTables. The documentation and features of this release are subject to change.

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);