1 | <?php |
||
18 | class Builder |
||
19 | { |
||
20 | /** |
||
21 | * @var Collection |
||
22 | */ |
||
23 | public $collection; |
||
24 | |||
25 | /** |
||
26 | * @var Repository |
||
27 | */ |
||
28 | public $config; |
||
29 | |||
30 | /** |
||
31 | * @var Factory |
||
32 | */ |
||
33 | public $view; |
||
34 | |||
35 | /** |
||
36 | * @var HtmlBuilder |
||
37 | */ |
||
38 | public $html; |
||
39 | |||
40 | /** |
||
41 | * @var UrlGenerator |
||
42 | */ |
||
43 | public $url; |
||
44 | |||
45 | /** |
||
46 | * @var FormBuilder |
||
47 | */ |
||
48 | public $form; |
||
49 | |||
50 | /** |
||
51 | * @var string|array |
||
52 | */ |
||
53 | protected $ajax = ''; |
||
54 | |||
55 | /** |
||
56 | * @var array |
||
57 | */ |
||
58 | protected $tableAttributes = ['class' => 'table', 'id' => 'dataTableBuilder']; |
||
59 | |||
60 | /** |
||
61 | * @var string |
||
62 | */ |
||
63 | protected $template = ''; |
||
64 | |||
65 | /** |
||
66 | * @var array |
||
67 | */ |
||
68 | protected $attributes = []; |
||
69 | |||
70 | /** |
||
71 | * Lists of valid DataTables Callbacks. |
||
72 | * |
||
73 | * @link https://datatables.net/reference/option/. |
||
74 | * @var array |
||
75 | */ |
||
76 | protected $validCallbacks = [ |
||
77 | 'createdRow', |
||
78 | 'drawCallback', |
||
79 | 'footerCallback', |
||
80 | 'formatNumber', |
||
81 | 'headerCallback', |
||
82 | 'infoCallback', |
||
83 | 'initComplete', |
||
84 | 'preDrawCallback', |
||
85 | 'rowCallback', |
||
86 | 'stateLoadCallback', |
||
87 | 'stateLoaded', |
||
88 | 'stateLoadParams', |
||
89 | 'stateSaveCallback', |
||
90 | 'stateSaveParams', |
||
91 | ]; |
||
92 | |||
93 | /** |
||
94 | * @param Repository $config |
||
95 | * @param Factory $view |
||
96 | * @param HtmlBuilder $html |
||
97 | * @param UrlGenerator $url |
||
98 | * @param FormBuilder $form |
||
99 | */ |
||
100 | public function __construct( |
||
114 | |||
115 | /** |
||
116 | * Generate DataTable javascript. |
||
117 | * |
||
118 | * @param null $script |
||
119 | * @param array $attributes |
||
120 | * @return string |
||
121 | */ |
||
122 | public function scripts($script = null, array $attributes = ['type' => 'text/javascript']) |
||
128 | |||
129 | /** |
||
130 | * Get generated raw scripts. |
||
131 | * |
||
132 | * @return string |
||
133 | */ |
||
134 | public function generateScripts() |
||
150 | |||
151 | /** |
||
152 | * Generate datatable js parameters. |
||
153 | * |
||
154 | * @param array $attributes |
||
155 | * @return string |
||
156 | */ |
||
157 | public function parameterize($attributes = []) |
||
192 | |||
193 | /** |
||
194 | * Compile DataTable callback value. |
||
195 | * |
||
196 | * @param mixed $callback |
||
197 | * @return mixed|string |
||
198 | */ |
||
199 | private function compileCallback($callback) |
||
209 | |||
210 | /** |
||
211 | * Get javascript template to use. |
||
212 | * |
||
213 | * @return string |
||
214 | */ |
||
215 | protected function template() |
||
221 | |||
222 | /** |
||
223 | * Add a column in collection using attributes. |
||
224 | * |
||
225 | * @param array $attributes |
||
226 | * @return $this |
||
227 | */ |
||
228 | public function addColumn(array $attributes) |
||
234 | |||
235 | /** |
||
236 | * Add a Column object in collection. |
||
237 | * |
||
238 | * @param \Yajra\Datatables\Html\Column $column |
||
239 | * @return $this |
||
240 | */ |
||
241 | public function add(Column $column) |
||
247 | |||
248 | /** |
||
249 | * Set datatables columns from array definition. |
||
250 | * |
||
251 | * @param array $columns |
||
252 | * @return $this |
||
253 | */ |
||
254 | public function columns(array $columns) |
||
272 | |||
273 | /** |
||
274 | * Set title attribute of an array if not set. |
||
275 | * |
||
276 | * @param string $title |
||
277 | * @param array $attributes |
||
278 | * @return array |
||
279 | */ |
||
280 | public function setTitle($title, array $attributes) |
||
288 | |||
289 | /** |
||
290 | * Convert string into a readable title. |
||
291 | * |
||
292 | * @param string $title |
||
293 | * @return string |
||
294 | */ |
||
295 | public function getQualifiedTitle($title) |
||
299 | |||
300 | /** |
||
301 | * Add a checkbox column. |
||
302 | * |
||
303 | * @param array $attributes |
||
304 | * @return $this |
||
305 | */ |
||
306 | public function addCheckbox(array $attributes = []) |
||
323 | |||
324 | /** |
||
325 | * Add a action column. |
||
326 | * |
||
327 | * @param array $attributes |
||
328 | * @return $this |
||
329 | */ |
||
330 | public function addAction(array $attributes = []) |
||
347 | |||
348 | /** |
||
349 | * Setup ajax parameter |
||
350 | * |
||
351 | * @param string|array $attributes |
||
352 | * @return $this |
||
353 | */ |
||
354 | public function ajax($attributes) |
||
360 | |||
361 | /** |
||
362 | * Generate DataTable's table html. |
||
363 | * |
||
364 | * @param array $attributes |
||
365 | * @return string |
||
366 | */ |
||
367 | public function table(array $attributes = []) |
||
373 | |||
374 | /** |
||
375 | * Configure DataTable's parameters. |
||
376 | * |
||
377 | * @param array $attributes |
||
378 | * @return $this |
||
379 | */ |
||
380 | public function parameters(array $attributes = []) |
||
386 | |||
387 | /** |
||
388 | * Set custom javascript template. |
||
389 | * |
||
390 | * @param string $template |
||
391 | * @return $this |
||
392 | */ |
||
393 | public function setTemplate($template) |
||
399 | |||
400 | /** |
||
401 | * Get collection of columns. |
||
402 | * |
||
403 | * @return Collection |
||
404 | */ |
||
405 | public function getColumns() |
||
409 | } |
||
410 |