File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 1+ # Sending parameter to DataTable class
2+ You can send a parameter from controller to dataTable class using ` with ` api.
3+
4+
5+ ## Example:
6+
7+ ``` php
8+ Route::get('datatable/{id}', function(UsersDataTable $dataTable, $id){
9+ return $dataTable->with('id', $id)
10+ ->with([
11+ 'key2' => 'value2',
12+ 'key3' => 'value3',
13+ ])
14+ ->render('path.to.view');
15+ });
16+ ```
17+
18+ You can then get the variable as a local property of the class.
19+
20+ ``` php
21+ class UsersDataTable {
22+ public function query() {
23+ return User::where('id', $this->id);
24+ }
25+ }
26+ ```
Original file line number Diff line number Diff line change 8080 - [Quick Starter](/docs/{{package}}/{{version}}/buttons-starter)
8181 - [DataTable Buttons](/docs/{{package}}/{{version}}/buttons-export)
8282 - [Custom Actions](/docs/{{package}}/{{version}}/buttons-custom)
83+ - [Sending Parameters](/docs/{{package}}/{{version}}/buttons-with)
8384 - [Extended DataTable](/docs/{{package}}/{{version}}/buttons-extended)
8485 - [Artisan Console](/docs/{{package}}/{{version}}/buttons-console)
8586 - [Github](https://github.com/yajra/laravel-datatables-buttons)
You can’t perform that action at this time.
0 commit comments