Skip to content

Commit f14c27d

Browse files
committed
Add docs for sending parameters from controller to dataTable class.
1 parent 72f1d3e commit f14c27d

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

buttons-with.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
```

documentation.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
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)

0 commit comments

Comments
 (0)