3
3
namespace Yajra \DataTables \Utilities ;
4
4
5
5
use Illuminate \Http \Request as BaseRequest ;
6
- use Yajra \DataTables \Exceptions \Exception ;
7
6
8
7
/**
9
8
* @mixin \Illuminate\Http\Request
@@ -54,7 +53,7 @@ public function __get($name)
54
53
*
55
54
* @return array
56
55
*/
57
- public function columns ()
56
+ public function columns (): array
58
57
{
59
58
return (array ) $ this ->request ->input ('columns ' );
60
59
}
@@ -64,7 +63,7 @@ public function columns()
64
63
*
65
64
* @return bool
66
65
*/
67
- public function isSearchable ()
66
+ public function isSearchable (): bool
68
67
{
69
68
return $ this ->request ->input ('search.value ' ) != '' ;
70
69
}
@@ -75,7 +74,7 @@ public function isSearchable()
75
74
* @param int $index
76
75
* @return bool
77
76
*/
78
- public function isRegex ($ index )
77
+ public function isRegex (int $ index ): bool
79
78
{
80
79
return $ this ->request ->input ("columns. $ index.search.regex " ) === 'true ' ;
81
80
}
@@ -85,7 +84,7 @@ public function isRegex($index)
85
84
*
86
85
* @return array
87
86
*/
88
- public function orderableColumns ()
87
+ public function orderableColumns (): array
89
88
{
90
89
if (! $ this ->isOrderable ()) {
91
90
return [];
@@ -113,7 +112,7 @@ public function orderableColumns()
113
112
*
114
113
* @return bool
115
114
*/
116
- public function isOrderable ()
115
+ public function isOrderable (): bool
117
116
{
118
117
return $ this ->request ->input ('order ' ) && count ((array ) $ this ->request ->input ('order ' )) > 0 ;
119
118
}
@@ -124,7 +123,7 @@ public function isOrderable()
124
123
* @param int $index
125
124
* @return bool
126
125
*/
127
- public function isColumnOrderable ($ index )
126
+ public function isColumnOrderable (int $ index ): bool
128
127
{
129
128
return $ this ->request ->input ("columns. $ index.orderable " , 'true ' ) == 'true ' ;
130
129
}
@@ -133,8 +132,6 @@ public function isColumnOrderable($index)
133
132
* Get searchable column indexes.
134
133
*
135
134
* @return array
136
- *
137
- * @throws \Yajra\DataTables\Exceptions\Exception
138
135
*/
139
136
public function searchableColumnIndex ()
140
137
{
@@ -155,10 +152,8 @@ public function searchableColumnIndex()
155
152
* @param int $i
156
153
* @param bool $column_search
157
154
* @return bool
158
- *
159
- * @throws \Yajra\DataTables\Exceptions\Exception
160
155
*/
161
- public function isColumnSearchable ($ i , $ column_search = true )
156
+ public function isColumnSearchable (int $ i , bool $ column_search = true ): bool
162
157
{
163
158
if ($ column_search ) {
164
159
return
@@ -181,11 +176,10 @@ public function isColumnSearchable($i, $column_search = true)
181
176
*
182
177
* @param int $index
183
178
* @return string
184
- *
185
- * @throws \Yajra\DataTables\Exceptions\Exception
186
179
*/
187
- public function columnKeyword ($ index ): string
180
+ public function columnKeyword (int $ index ): string
188
181
{
182
+ /** @var string $keyword */
189
183
$ keyword = $ this ->request ->input ("columns. $ index.search.value " ) ?? '' ;
190
184
191
185
return $ this ->prepareKeyword ($ keyword );
@@ -194,40 +188,33 @@ public function columnKeyword($index): string
194
188
/**
195
189
* Prepare keyword string value.
196
190
*
197
- * @param mixed $keyword
191
+ * @param float|array|int|string $keyword
198
192
* @return string
199
- *
200
- * @throws \Yajra\DataTables\Exceptions\Exception
201
193
*/
202
- protected function prepareKeyword ($ keyword ): string
194
+ protected function prepareKeyword (float | array | int | string $ keyword ): string
203
195
{
204
196
if (is_array ($ keyword )) {
205
197
return implode (' ' , $ keyword );
206
198
}
207
199
208
- if (is_string ($ keyword )) {
209
- return $ keyword ;
210
- }
211
-
212
- throw new Exception ('Invalid keyword value. ' );
200
+ return (string ) $ keyword ;
213
201
}
214
202
215
203
/**
216
204
* Get global search keyword.
217
205
*
218
206
* @return string
219
- *
220
- * @throws \Yajra\DataTables\Exceptions\Exception
221
207
*/
222
208
public function keyword (): string
223
209
{
210
+ /** @var string $keyword */
224
211
$ keyword = $ this ->request ->input ('search.value ' ) ?? '' ;
225
212
226
213
return $ this ->prepareKeyword ($ keyword );
227
214
}
228
215
229
216
/**
230
- * Get column identity from input or database .
217
+ * Get column name by index .
231
218
*
232
219
* @param int $i
233
220
* @return string|null
@@ -260,6 +247,11 @@ public function getBaseRequest(): BaseRequest
260
247
return $ this ->request ;
261
248
}
262
249
250
+ /**
251
+ * Get starting record value.
252
+ *
253
+ * @return int
254
+ */
263
255
public function start (): int
264
256
{
265
257
/** @var int $start */
@@ -268,6 +260,11 @@ public function start(): int
268
260
return $ start ;
269
261
}
270
262
263
+ /**
264
+ * Get per page length.
265
+ *
266
+ * @return int
267
+ */
271
268
public function length (): int
272
269
{
273
270
/** @var int $length */
@@ -276,6 +273,11 @@ public function length(): int
276
273
return $ length ;
277
274
}
278
275
276
+ /**
277
+ * Get draw request.
278
+ *
279
+ * @return int
280
+ */
279
281
public function draw (): int
280
282
{
281
283
/** @var int $draw */
0 commit comments