1 | <?php |
||
10 | class AttributesDataTable extends AbstractDataTable |
||
11 | { |
||
12 | /** |
||
13 | * {@inheritdoc} |
||
14 | */ |
||
15 | protected $model = Attribute::class; |
||
16 | |||
17 | /** |
||
18 | * {@inheritdoc} |
||
19 | */ |
||
20 | protected $builderParameters = [ |
||
21 | 'drawCallback' => 'function (settings) { |
||
22 | var lastGroup = null; |
||
23 | var api = this.api(); |
||
24 | var colspan = api.columns(\':visible\').count(); |
||
25 | var rows = api.rows({page:\'current\'}).nodes(); |
||
26 | |||
27 | api.column(\'group:name\', {page:\'current\'} ).data().each(function (rowGroup, rowIndex) { |
||
28 | if (lastGroup !== rowGroup) { |
||
29 | $(rows).eq(rowIndex).before( |
||
30 | \'<tr class="attribute-group"><td colspan="\'+colspan+\'"><strong>\'+(rowGroup ? rowGroup : "No Group")+\'</strong></td></tr>\' |
||
|
|||
31 | ); |
||
32 | |||
33 | lastGroup = rowGroup; |
||
34 | } |
||
35 | }); |
||
36 | }', |
||
37 | ]; |
||
38 | |||
39 | /** |
||
40 | * Get the query object to be processed by dataTables. |
||
41 | * |
||
42 | * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder|\Illuminate\Support\Collection |
||
43 | */ |
||
44 | public function query() |
||
51 | |||
52 | /** |
||
53 | * Display ajax response. |
||
54 | * |
||
55 | * @return \Illuminate\Http\JsonResponse |
||
56 | */ |
||
57 | public function ajax() |
||
63 | |||
64 | /** |
||
65 | * Get columns. |
||
66 | * |
||
67 | * @return array |
||
68 | */ |
||
69 | protected function getColumns(): array |
||
86 | } |
||
87 |
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.