11
11
12
12
class Builder
13
13
{
14
- use Macroable;
15
- use HasOptions;
16
- use HasTable;
17
- use HasEditor;
18
- use Columns \Index;
19
14
use Columns \Action;
20
15
use Columns \Checkbox;
16
+ use Columns \Index;
17
+ use HasEditor;
18
+ use HasOptions;
19
+ use HasTable;
20
+ use Macroable;
21
21
22
22
// Select plugin constants.
23
23
const SELECT_STYLE_API = 'api ' ;
24
+
24
25
const SELECT_STYLE_SINGLE = 'single ' ;
26
+
25
27
const SELECT_STYLE_MULTI = 'multi ' ;
28
+
26
29
const SELECT_STYLE_OS = 'os ' ;
30
+
27
31
const SELECT_STYLE_MULTI_SHIFT = 'multi+shift ' ;
32
+
28
33
const SELECT_ITEMS_ROW = 'row ' ;
34
+
29
35
const SELECT_ITEMS_COLUMN = 'column ' ;
36
+
30
37
const SELECT_ITEMS_CELL = 'cell ' ;
31
38
32
39
/**
@@ -44,31 +51,14 @@ class Builder
44
51
*/
45
52
protected array $ tableAttributes = [];
46
53
47
- /**
48
- * @var string
49
- */
50
54
protected string $ template = '' ;
51
55
52
- /**
53
- * @var array
54
- */
55
56
protected array $ attributes = [];
56
57
57
- /**
58
- * @var string|array
59
- */
60
58
protected string |array $ ajax = '' ;
61
59
62
- /**
63
- * @var array
64
- */
65
60
protected array $ additionalScripts = [];
66
61
67
- /**
68
- * @param Repository $config
69
- * @param Factory $view
70
- * @param HtmlBuilder $html
71
- */
72
62
public function __construct (public Repository $ config , public Factory $ view , public HtmlBuilder $ html )
73
63
{
74
64
/** @var array $defaults */
@@ -100,12 +90,8 @@ public static function useWebpack(): void
100
90
101
91
/**
102
92
* Generate DataTable javascript.
103
- *
104
- * @param string|null $script
105
- * @param array $attributes
106
- * @return \Illuminate\Support\HtmlString
107
93
*/
108
- public function scripts (string $ script = null , array $ attributes = []): HtmlString
94
+ public function scripts (? string $ script = null , array $ attributes = []): HtmlString
109
95
{
110
96
$ script = $ script ?: $ this ->generateScripts ();
111
97
$ attributes = $ this ->html ->attributes (
@@ -117,8 +103,6 @@ public function scripts(string $script = null, array $attributes = []): HtmlStri
117
103
118
104
/**
119
105
* Get generated raw scripts.
120
- *
121
- * @return \Illuminate\Support\HtmlString
122
106
*/
123
107
public function generateScripts (): HtmlString
124
108
{
@@ -131,8 +115,6 @@ public function generateScripts(): HtmlString
131
115
132
116
/**
133
117
* Get generated json configuration.
134
- *
135
- * @return string
136
118
*/
137
119
public function generateJson (): string
138
120
{
@@ -141,9 +123,6 @@ public function generateJson(): string
141
123
142
124
/**
143
125
* Generate DataTables js parameters.
144
- *
145
- * @param array $attributes
146
- * @return string
147
126
*/
148
127
public function parameterize (array $ attributes = []): string
149
128
{
@@ -154,8 +133,6 @@ public function parameterize(array $attributes = []): string
154
133
155
134
/**
156
135
* Get DataTable options array.
157
- *
158
- * @return array
159
136
*/
160
137
public function getOptions (): array
161
138
{
@@ -174,8 +151,6 @@ public function getOptions(): array
174
151
175
152
/**
176
153
* Get javascript template to use.
177
- *
178
- * @return string
179
154
*/
180
155
protected function template (): string
181
156
{
@@ -189,11 +164,6 @@ protected function template(): string
189
164
190
165
/**
191
166
* Generate DataTable's table html.
192
- *
193
- * @param array $attributes
194
- * @param bool $drawFooter
195
- * @param bool $drawSearch
196
- * @return \Illuminate\Support\HtmlString
197
167
*/
198
168
public function table (array $ attributes = [], bool $ drawFooter = false , bool $ drawSearch = false ): HtmlString
199
169
{
@@ -223,7 +193,6 @@ public function table(array $attributes = [], bool $drawFooter = false, bool $dr
223
193
/**
224
194
* Configure DataTable's parameters.
225
195
*
226
- * @param array $attributes
227
196
* @return $this
228
197
*/
229
198
public function parameters (array $ attributes = []): static
@@ -246,7 +215,6 @@ public function asOptions(): static
246
215
/**
247
216
* Set custom javascript template.
248
217
*
249
- * @param string $template
250
218
* @return $this
251
219
*/
252
220
public function setTemplate (string $ template ): static
@@ -266,29 +234,17 @@ public function asFunction(): static
266
234
return $ this ->setTemplate ('datatables::function ' );
267
235
}
268
236
269
- /**
270
- * @return array
271
- */
272
237
public function getAttributes (): array
273
238
{
274
239
return $ this ->attributes ;
275
240
}
276
241
277
- /**
278
- * @param string $key
279
- * @param mixed $default
280
- * @return mixed
281
- */
282
242
public function getAttribute (string $ key , mixed $ default = '' ): mixed
283
243
{
284
244
return $ this ->attributes [$ key ] ?? $ default ;
285
245
}
286
246
287
- /**
288
- * @param string|null $key
289
- * @return array|string
290
- */
291
- public function getAjax (string $ key = null ): array |string
247
+ public function getAjax (?string $ key = null ): array |string
292
248
{
293
249
if (! is_null ($ key )) {
294
250
return $ this ->ajax [$ key ] ?? '' ;
@@ -300,7 +256,6 @@ public function getAjax(string $key = null): array|string
300
256
/**
301
257
* Add additional scripts to the DataTables JS initialization.
302
258
*
303
- * @param string $view
304
259
* @return $this
305
260
*/
306
261
public function addScript (string $ view ): static
0 commit comments