1 | <?php |
||
11 | class AttributesDataTable extends AbstractDataTable |
||
12 | { |
||
13 | /** |
||
14 | * {@inheritdoc} |
||
15 | */ |
||
16 | protected $model = AttributeContract::class; |
||
17 | |||
18 | /** |
||
19 | * {@inheritdoc} |
||
20 | */ |
||
21 | protected $transformer = AttributeTransformer::class; |
||
22 | |||
23 | /** |
||
24 | * Get the query object to be processed by dataTables. |
||
25 | * |
||
26 | * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder|\Illuminate\Support\Collection |
||
|
|||
27 | */ |
||
28 | public function query() |
||
35 | |||
36 | /** |
||
37 | * Get default builder parameters. |
||
38 | * |
||
39 | * @return array |
||
40 | */ |
||
41 | protected function getBuilderParameters() |
||
42 | { |
||
43 | return [ |
||
44 | 'keys' => true, |
||
45 | 'autoWidth' => false, |
||
46 | 'dom' => "<'row'<'col-sm-6'B><'col-sm-6'f>> <'row'r><'row'<'col-sm-12't>> <'row'<'col-sm-5'i><'col-sm-7'p>>", |
||
47 | 'buttons' => [ |
||
48 | ['extend' => 'create', 'text' => '<i class="fa fa-plus"></i> '.trans('cortex/foundation::common.new')], 'print', 'reset', 'reload', 'export', |
||
49 | ['extend' => 'colvis', 'text' => '<i class="fa fa-columns"></i> '.trans('cortex/foundation::common.columns').' <span class="caret"/>'], |
||
50 | ['extend' => 'pageLength', 'text' => '<i class="fa fa-list-ol"></i> '.trans('cortex/foundation::common.limit').' <span class="caret"/>'], |
||
51 | ], |
||
52 | 'drawCallback' => 'function (settings) { |
||
53 | var lastGroup = null; |
||
54 | var api = this.api(); |
||
55 | var colspan = api.columns(\':visible\').count(); |
||
56 | var rows = api.rows({page:\'current\'}).nodes(); |
||
57 | |||
58 | api.column(\'group:name\', {page:\'current\'} ).data().each(function (rowGroup, rowIndex) { |
||
59 | if (lastGroup !== rowGroup) { |
||
60 | $(rows).eq(rowIndex).before( |
||
61 | \'<tr class="attribute-group"><td colspan="\'+colspan+\'"><strong>\'+(rowGroup ? rowGroup : "No Group")+\'</strong></td></tr>\' |
||
62 | ); |
||
63 | |||
64 | lastGroup = rowGroup; |
||
65 | } |
||
66 | }); |
||
67 | }', |
||
68 | ]; |
||
69 | } |
||
70 | |||
71 | /** |
||
72 | * Display ajax response. |
||
73 | * |
||
74 | * @return \Illuminate\Http\JsonResponse |
||
75 | */ |
||
76 | public function ajax() |
||
85 | |||
86 | /** |
||
87 | * Get columns. |
||
88 | * |
||
89 | * @return array |
||
90 | */ |
||
91 | protected function getColumns() |
||
108 | } |
||
109 |
This check looks for the generic type
array
as a return type and suggests a more specific type. This type is inferred from the actual code.