1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Yajra\DataTables\Html\Options; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* DataTables - Callbacks option builder. |
7
|
|
|
* |
8
|
|
|
* @see https://datatables.net/reference/option/ |
9
|
|
|
*/ |
10
|
|
|
trait HasCallbacks |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* Set createdRow option value. |
14
|
|
|
* |
15
|
|
|
* @param mixed $script |
16
|
|
|
* @return $this |
17
|
|
|
* @see https://datatables.net/reference/option/createdRow |
18
|
|
|
*/ |
19
|
|
|
public function createdRow($script) |
20
|
|
|
{ |
21
|
|
|
$this->attributes['createdRow'] = $script; |
|
|
|
|
22
|
|
|
|
23
|
|
|
return $this; |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Set drawCallback option value. |
28
|
|
|
* |
29
|
|
|
* @param mixed $script |
30
|
|
|
* @return $this |
31
|
|
|
* @see https://datatables.net/reference/option/drawCallback |
32
|
|
|
*/ |
33
|
|
|
public function drawCallback($script) |
34
|
|
|
{ |
35
|
|
|
$this->attributes['drawCallback'] = $script; |
36
|
|
|
|
37
|
|
|
return $this; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Set footerCallback option value. |
42
|
|
|
* |
43
|
|
|
* @param mixed $script |
44
|
|
|
* @return $this |
45
|
|
|
* @see https://datatables.net/reference/option/footerCallback |
46
|
|
|
*/ |
47
|
|
|
public function footerCallback($script) |
48
|
|
|
{ |
49
|
|
|
$this->attributes['footerCallback'] = $script; |
50
|
|
|
|
51
|
|
|
return $this; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Set formatNumber option value. |
56
|
|
|
* |
57
|
|
|
* @param mixed $script |
58
|
|
|
* @return $this |
59
|
|
|
* @see https://datatables.net/reference/option/formatNumber |
60
|
|
|
*/ |
61
|
|
|
public function formatNumber($script) |
62
|
|
|
{ |
63
|
|
|
$this->attributes['formatNumber'] = $script; |
64
|
|
|
|
65
|
|
|
return $this; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Set headerCallback option value. |
70
|
|
|
* |
71
|
|
|
* @param mixed $script |
72
|
|
|
* @return $this |
73
|
|
|
* @see https://datatables.net/reference/option/headerCallback |
74
|
|
|
*/ |
75
|
|
|
public function headerCallback($script) |
76
|
|
|
{ |
77
|
|
|
$this->attributes['headerCallback'] = $script; |
78
|
|
|
|
79
|
|
|
return $this; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Set infoCallback option value. |
84
|
|
|
* |
85
|
|
|
* @param mixed $script |
86
|
|
|
* @return $this |
87
|
|
|
* @see https://datatables.net/reference/option/infoCallback |
88
|
|
|
*/ |
89
|
|
|
public function infoCallback($script) |
90
|
|
|
{ |
91
|
|
|
$this->attributes['infoCallback'] = $script; |
92
|
|
|
|
93
|
|
|
return $this; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Set initComplete option value. |
98
|
|
|
* |
99
|
|
|
* @param mixed $script |
100
|
|
|
* @return $this |
101
|
|
|
* @see https://datatables.net/reference/option/initComplete |
102
|
|
|
*/ |
103
|
|
|
public function initComplete($script) |
104
|
|
|
{ |
105
|
|
|
$this->attributes['initComplete'] = $script; |
106
|
|
|
|
107
|
|
|
return $this; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* Set preDrawCallback option value. |
112
|
|
|
* |
113
|
|
|
* @param mixed $script |
114
|
|
|
* @return $this |
115
|
|
|
* @see https://datatables.net/reference/option/preDrawCallback |
116
|
|
|
*/ |
117
|
|
|
public function preDrawCallback($script) |
118
|
|
|
{ |
119
|
|
|
$this->attributes['preDrawCallback'] = $script; |
120
|
|
|
|
121
|
|
|
return $this; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* Set rowCallback option value. |
126
|
|
|
* |
127
|
|
|
* @param mixed $script |
128
|
|
|
* @return $this |
129
|
|
|
* @see https://datatables.net/reference/option/rowCallback |
130
|
|
|
*/ |
131
|
|
|
public function rowCallback($script) |
132
|
|
|
{ |
133
|
|
|
$this->attributes['rowCallback'] = $script; |
134
|
|
|
|
135
|
|
|
return $this; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* Set stateLoadCallback option value. |
140
|
|
|
* |
141
|
|
|
* @param mixed $script |
142
|
|
|
* @return $this |
143
|
|
|
* @see https://datatables.net/reference/option/stateLoadCallback |
144
|
|
|
*/ |
145
|
|
|
public function stateLoadCallback($script) |
146
|
|
|
{ |
147
|
|
|
$this->attributes['stateLoadCallback'] = $script; |
148
|
|
|
|
149
|
|
|
return $this; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* Set stateLoaded option value. |
154
|
|
|
* |
155
|
|
|
* @param mixed $script |
156
|
|
|
* @return $this |
157
|
|
|
* @see https://datatables.net/reference/option/stateLoaded |
158
|
|
|
*/ |
159
|
|
|
public function stateLoaded($script) |
160
|
|
|
{ |
161
|
|
|
$this->attributes['stateLoaded'] = $script; |
162
|
|
|
|
163
|
|
|
return $this; |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* Set stateLoadParams option value. |
168
|
|
|
* |
169
|
|
|
* @param mixed $script |
170
|
|
|
* @return $this |
171
|
|
|
* @see https://datatables.net/reference/option/stateLoadParams |
172
|
|
|
*/ |
173
|
|
|
public function stateLoadParams($script) |
174
|
|
|
{ |
175
|
|
|
$this->attributes['stateLoadParams'] = $script; |
176
|
|
|
|
177
|
|
|
return $this; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* Set stateSaveCallback option value. |
182
|
|
|
* |
183
|
|
|
* @param mixed $script |
184
|
|
|
* @return $this |
185
|
|
|
* @see https://datatables.net/reference/option/stateSaveCallback |
186
|
|
|
*/ |
187
|
|
|
public function stateSaveCallback($script) |
188
|
|
|
{ |
189
|
|
|
$this->attributes['stateSaveCallback'] = $script; |
190
|
|
|
|
191
|
|
|
return $this; |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* Set stateSaveParams option value. |
196
|
|
|
* |
197
|
|
|
* @param mixed $script |
198
|
|
|
* @return $this |
199
|
|
|
* @see https://datatables.net/reference/option/stateSaveParams |
200
|
|
|
*/ |
201
|
|
|
public function stateSaveParams($script) |
202
|
|
|
{ |
203
|
|
|
$this->attributes['stateSaveParams'] = $script; |
204
|
|
|
|
205
|
|
|
return $this; |
206
|
|
|
} |
207
|
|
|
} |
208
|
|
|
|
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: