Skip to content

Commit a179773

Browse files
committed
Update dataTable service stub.
1 parent 2b85636 commit a179773

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

src/Generators/stubs/datatables.stub

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use Yajra\Datatables\Services\DataTable;
77

88
class DummyClass extends DataTable
99
{
10-
// protected $printPreview = 'path-to-print-preview-view';
10+
// protected $printPreview = 'path.to.print.preview.view';
1111
// protected $exportColumns = ['id', 'name'];
1212
// protected $printColumns = '*';
1313

@@ -19,7 +19,8 @@ class DummyClass extends DataTable
1919
public function ajax()
2020
{
2121
return $this->datatables
22-
->of($this->query())
22+
->eloquent($this->query())
23+
->addColumn('action', 'path.to.action.view')
2324
->make(true);
2425
}
2526

@@ -30,7 +31,7 @@ class DummyClass extends DataTable
3031
*/
3132
public function query()
3233
{
33-
$users = User::select();
34+
$users = User::query();
3435

3536
return $this->applyScopes($users);
3637
}
@@ -45,10 +46,28 @@ class DummyClass extends DataTable
4546
return $this->builder()
4647
->columns([
4748
'id',
49+
// add columns to display
50+
'created_at',
51+
'updated_at',
4852
])
53+
->addAction(['width' => '50px'])
4954
->ajax('')
5055
->parameters([
51-
'buttons' => ['csv', 'excel', 'pdf', 'print'],
56+
'buttons' => [
57+
'create',
58+
[
59+
'extend' => 'collection',
60+
'text' => '<i class="fa fa-download"></i> Export',
61+
'buttons' => [
62+
'csv',
63+
'excel',
64+
'pdf',
65+
],
66+
],
67+
'print',
68+
'reset',
69+
'reload',
70+
],
5271
]);
5372
}
5473
}

0 commit comments

Comments
 (0)