Skip to content

Latest commit

 

History

History
26 lines (21 loc) · 582 Bytes

buttons-with.md

File metadata and controls

26 lines (21 loc) · 582 Bytes

Sending parameter to DataTable class

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

Example:

Route::get('datatable/{id}', function(UsersDataTable $dataTable, $id){
   return $dataTable->with('id', $id)
           ->with([
                'key2' => 'value2',
                'key3' => 'value3',
           ])
           ->render('path.to.view');
});

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

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