1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Yajra\DataTables\Html\Options\Plugins; |
4
|
|
|
|
5
|
|
|
use Yajra\DataTables\Html\Builder; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* DataTables - Select plugin option builder. |
9
|
|
|
* |
10
|
|
|
* @see https://datatables.net/extensions/select |
11
|
|
|
* @see https://datatables.net/reference/option/select |
12
|
|
|
*/ |
13
|
|
|
trait Select |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* Set select option value. |
17
|
|
|
* |
18
|
|
|
* @param bool|array $value |
19
|
|
|
* @return $this |
20
|
|
|
* @see https://datatables.net/reference/option/select |
21
|
|
|
*/ |
22
|
|
|
public function select($value = true) |
23
|
|
|
{ |
24
|
|
|
$this->attributes['select'] = $value; |
|
|
|
|
25
|
|
|
|
26
|
|
|
return $this; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Set select blurable option value. |
31
|
|
|
* |
32
|
|
|
* @param bool $value |
33
|
|
|
* @return $this |
34
|
|
|
* @see https://datatables.net/reference/option/select.blurable |
35
|
|
|
*/ |
36
|
|
|
public function selectBlurable(bool $value = true) |
37
|
|
|
{ |
38
|
|
|
$this->attributes['select']['blurable'] = $value; |
39
|
|
|
|
40
|
|
|
return $this; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Set select className option value. |
45
|
|
|
* |
46
|
|
|
* @param string $value |
47
|
|
|
* @return $this |
48
|
|
|
* @see https://datatables.net/reference/option/select.className |
49
|
|
|
*/ |
50
|
|
|
public function selectClassName($value = 'selected') |
51
|
|
|
{ |
52
|
|
|
$this->attributes['select']['className'] = $value; |
53
|
|
|
|
54
|
|
|
return $this; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Set select info option value. |
59
|
|
|
* |
60
|
|
|
* @param bool $value |
61
|
|
|
* @return $this |
62
|
|
|
* @see https://datatables.net/reference/option/select.info |
63
|
|
|
*/ |
64
|
|
|
public function selectInfo(bool $value = true) |
65
|
|
|
{ |
66
|
|
|
$this->attributes['select']['info'] = $value; |
67
|
|
|
|
68
|
|
|
return $this; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Set select items option value. |
73
|
|
|
* |
74
|
|
|
* @param string $value |
75
|
|
|
* @return $this |
76
|
|
|
* @see https://datatables.net/reference/option/select.items |
77
|
|
|
*/ |
78
|
|
|
public function selectItems($value = 'row') |
79
|
|
|
{ |
80
|
|
|
$this->attributes['select']['items'] = $value; |
81
|
|
|
|
82
|
|
|
return $this; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Set select items option value to row. |
87
|
|
|
* |
88
|
|
|
* @return $this |
89
|
|
|
* @see https://datatables.net/reference/option/select.items |
90
|
|
|
*/ |
91
|
|
|
public function selectItemsRow() |
92
|
|
|
{ |
93
|
|
|
$this->attributes['select']['items'] = Builder::SELECT_ITEMS_ROW; |
94
|
|
|
|
95
|
|
|
return $this; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* Set select items option value to column. |
100
|
|
|
* |
101
|
|
|
* @return $this |
102
|
|
|
* @see https://datatables.net/reference/option/select.items |
103
|
|
|
*/ |
104
|
|
|
public function selectItemsColumn() |
105
|
|
|
{ |
106
|
|
|
$this->attributes['select']['items'] = Builder::SELECT_ITEMS_COLUMN; |
107
|
|
|
|
108
|
|
|
return $this; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* Set select items option value to cell. |
113
|
|
|
* |
114
|
|
|
* @return $this |
115
|
|
|
* @see https://datatables.net/reference/option/select.items |
116
|
|
|
*/ |
117
|
|
|
public function selectItemsCell() |
118
|
|
|
{ |
119
|
|
|
$this->attributes['select']['items'] = Builder::SELECT_ITEMS_CELL; |
120
|
|
|
|
121
|
|
|
return $this; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* Set select selector option value. |
126
|
|
|
* |
127
|
|
|
* @param string $value |
128
|
|
|
* @return $this |
129
|
|
|
* @see https://datatables.net/reference/option/select.selector |
130
|
|
|
*/ |
131
|
|
|
public function selectSelector($value = 'td') |
132
|
|
|
{ |
133
|
|
|
$this->attributes['select']['selector'] = $value; |
134
|
|
|
|
135
|
|
|
return $this; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* Set select style option value. |
140
|
|
|
* |
141
|
|
|
* @param string $value |
142
|
|
|
* @return $this |
143
|
|
|
* @see https://datatables.net/reference/option/select.style |
144
|
|
|
*/ |
145
|
|
|
public function selectStyle($value = 'os') |
146
|
|
|
{ |
147
|
|
|
$this->attributes['select']['style'] = $value; |
148
|
|
|
|
149
|
|
|
return $this; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* Set select style option value to api. |
154
|
|
|
* |
155
|
|
|
* @return $this |
156
|
|
|
* @see https://datatables.net/reference/option/select.style |
157
|
|
|
*/ |
158
|
|
|
public function selectStyleApi() |
159
|
|
|
{ |
160
|
|
|
$this->attributes['select']['style'] = Builder::SELECT_STYLE_API; |
161
|
|
|
|
162
|
|
|
return $this; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* Set select style option value to single. |
167
|
|
|
* |
168
|
|
|
* @return $this |
169
|
|
|
* @see https://datatables.net/reference/option/select.style |
170
|
|
|
*/ |
171
|
|
|
public function selectStyleSingle() |
172
|
|
|
{ |
173
|
|
|
$this->attributes['select']['style'] = Builder::SELECT_STYLE_SINGLE; |
174
|
|
|
|
175
|
|
|
return $this; |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
/** |
179
|
|
|
* Set select style option value to multi. |
180
|
|
|
* |
181
|
|
|
* @return $this |
182
|
|
|
* @see https://datatables.net/reference/option/select.style |
183
|
|
|
*/ |
184
|
|
|
public function selectStyleMulti() |
185
|
|
|
{ |
186
|
|
|
$this->attributes['select']['style'] = Builder::SELECT_STYLE_MULTI; |
187
|
|
|
|
188
|
|
|
return $this; |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* Set select style option value to os. |
193
|
|
|
* |
194
|
|
|
* @return $this |
195
|
|
|
* @see https://datatables.net/reference/option/select.style |
196
|
|
|
*/ |
197
|
|
|
public function selectStyleOS() |
198
|
|
|
{ |
199
|
|
|
$this->attributes['select']['style'] = Builder::SELECT_STYLE_OS; |
200
|
|
|
|
201
|
|
|
return $this; |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* Set select style option value to multi+shift. |
206
|
|
|
* |
207
|
|
|
* @return $this |
208
|
|
|
* @see https://datatables.net/reference/option/select.style |
209
|
|
|
*/ |
210
|
|
|
public function selectStyleMultiShift() |
211
|
|
|
{ |
212
|
|
|
$this->attributes['select']['style'] = Builder::SELECT_STYLE_MULTI_SHIFT; |
213
|
|
|
|
214
|
|
|
return $this; |
215
|
|
|
} |
216
|
|
|
} |
217
|
|
|
|
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: