99 */
1010class Request
1111{
12- protected BaseRequest $ request ;
13-
14- /**
15- * Request constructor.
16- */
17- public function __construct ()
18- {
19- $ this ->request = app ('request ' );
20- }
21-
2212 /**
2313 * Proxy non-existing method calls to base request class.
2414 *
@@ -28,7 +18,7 @@ public function __construct()
2818 */
2919 public function __call ($ name , $ arguments )
3020 {
31- $ callback = [$ this -> request , $ name ];
21+ $ callback = [request () , $ name ];
3222 if (is_callable ($ callback )) {
3323 return call_user_func_array ($ callback , $ arguments );
3424 }
@@ -42,31 +32,31 @@ public function __call($name, $arguments)
4232 */
4333 public function __get ($ name )
4434 {
45- return $ this -> request ->__get ($ name );
35+ return request () ->__get ($ name );
4636 }
4737
4838 /**
4939 * Get all columns request input.
5040 */
5141 public function columns (): array
5242 {
53- return (array ) $ this -> request ->input ('columns ' );
43+ return (array ) request () ->input ('columns ' );
5444 }
5545
5646 /**
5747 * Check if DataTables is searchable.
5848 */
5949 public function isSearchable (): bool
6050 {
61- return $ this -> request ->input ('search.value ' ) != '' ;
51+ return request () ->input ('search.value ' ) != '' ;
6252 }
6353
6454 /**
6555 * Check if DataTables must uses regular expressions.
6656 */
6757 public function isRegex (int $ index ): bool
6858 {
69- return $ this -> request ->input ("columns. $ index.search.regex " ) === 'true ' ;
59+ return request () ->input ("columns. $ index.search.regex " ) === 'true ' ;
7060 }
7161
7262 /**
@@ -79,12 +69,12 @@ public function orderableColumns(): array
7969 }
8070
8171 $ orderable = [];
82- for ($ i = 0 , $ c = count ((array ) $ this -> request ->input ('order ' )); $ i < $ c ; $ i ++) {
72+ for ($ i = 0 , $ c = count ((array ) request () ->input ('order ' )); $ i < $ c ; $ i ++) {
8373 /** @var int $order_col */
84- $ order_col = $ this -> request ->input ("order. $ i.column " );
74+ $ order_col = request () ->input ("order. $ i.column " );
8575
8676 /** @var string $direction */
87- $ direction = $ this -> request ->input ("order. $ i.dir " );
77+ $ direction = request () ->input ("order. $ i.dir " );
8878
8979 $ order_dir = $ direction && strtolower ($ direction ) === 'asc ' ? 'asc ' : 'desc ' ;
9080 if ($ this ->isColumnOrderable ($ order_col )) {
@@ -100,15 +90,15 @@ public function orderableColumns(): array
10090 */
10191 public function isOrderable (): bool
10292 {
103- return $ this -> request ->input ('order ' ) && count ((array ) $ this -> request ->input ('order ' )) > 0 ;
93+ return request () ->input ('order ' ) && count ((array ) request () ->input ('order ' )) > 0 ;
10494 }
10595
10696 /**
10797 * Check if a column is orderable.
10898 */
10999 public function isColumnOrderable (int $ index ): bool
110100 {
111- return $ this -> request ->input ("columns. $ index.orderable " , 'true ' ) == 'true ' ;
101+ return request () ->input ("columns. $ index.orderable " , 'true ' ) == 'true ' ;
112102 }
113103
114104 /**
@@ -119,7 +109,7 @@ public function isColumnOrderable(int $index): bool
119109 public function searchableColumnIndex ()
120110 {
121111 $ searchable = [];
122- $ columns = (array ) $ this -> request ->input ('columns ' );
112+ $ columns = (array ) request () ->input ('columns ' );
123113 for ($ i = 0 , $ c = count ($ columns ); $ i < $ c ; $ i ++) {
124114 if ($ this ->isColumnSearchable ($ i , false )) {
125115 $ searchable [] = $ i ;
@@ -137,17 +127,17 @@ public function isColumnSearchable(int $i, bool $column_search = true): bool
137127 if ($ column_search ) {
138128 return
139129 (
140- $ this -> request ->input ("columns. $ i.searchable " , 'true ' ) === 'true '
130+ request () ->input ("columns. $ i.searchable " , 'true ' ) === 'true '
141131 ||
142- $ this -> request ->input ("columns. $ i.searchable " , 'true ' ) === true
132+ request () ->input ("columns. $ i.searchable " , 'true ' ) === true
143133 )
144134 && $ this ->columnKeyword ($ i ) != '' ;
145135 }
146136
147137 return
148- $ this -> request ->input ("columns. $ i.searchable " , 'true ' ) === 'true '
138+ request () ->input ("columns. $ i.searchable " , 'true ' ) === 'true '
149139 ||
150- $ this -> request ->input ("columns. $ i.searchable " , 'true ' ) === true ;
140+ request () ->input ("columns. $ i.searchable " , 'true ' ) === true ;
151141 }
152142
153143 /**
@@ -156,7 +146,7 @@ public function isColumnSearchable(int $i, bool $column_search = true): bool
156146 public function columnKeyword (int $ index ): string
157147 {
158148 /** @var string $keyword */
159- $ keyword = $ this -> request ->input ("columns. $ index.search.value " ) ?? '' ;
149+ $ keyword = request () ->input ("columns. $ index.search.value " ) ?? '' ;
160150
161151 return $ this ->prepareKeyword ($ keyword );
162152 }
@@ -179,7 +169,7 @@ protected function prepareKeyword(float|array|int|string $keyword): string
179169 public function keyword (): string
180170 {
181171 /** @var string $keyword */
182- $ keyword = $ this -> request ->input ('search.value ' ) ?? '' ;
172+ $ keyword = request () ->input ('search.value ' ) ?? '' ;
183173
184174 return $ this ->prepareKeyword ($ keyword );
185175 }
@@ -190,7 +180,7 @@ public function keyword(): string
190180 public function columnName (int $ i ): ?string
191181 {
192182 /** @var string[] $column */
193- $ column = $ this -> request ->input ("columns. $ i " );
183+ $ column = request () ->input ("columns. $ i " );
194184
195185 return (isset ($ column ['name ' ]) && $ column ['name ' ] != '' ) ? $ column ['name ' ] : $ column ['data ' ];
196186 }
@@ -200,22 +190,22 @@ public function columnName(int $i): ?string
200190 */
201191 public function isPaginationable (): bool
202192 {
203- return ! is_null ($ this -> request ->input ('start ' )) &&
204- ! is_null ($ this -> request ->input ('length ' )) &&
205- $ this -> request ->input ('length ' ) != -1 ;
193+ return ! is_null (request () ->input ('start ' )) &&
194+ ! is_null (request () ->input ('length ' )) &&
195+ request () ->input ('length ' ) != -1 ;
206196 }
207197
208198 public function getBaseRequest (): BaseRequest
209199 {
210- return $ this -> request ;
200+ return request () ;
211201 }
212202
213203 /**
214204 * Get starting record value.
215205 */
216206 public function start (): int
217207 {
218- $ start = $ this -> request ->input ('start ' , 0 );
208+ $ start = request () ->input ('start ' , 0 );
219209
220210 return is_numeric ($ start ) ? intval ($ start ) : 0 ;
221211 }
@@ -225,7 +215,7 @@ public function start(): int
225215 */
226216 public function length (): int
227217 {
228- $ length = $ this -> request ->input ('length ' , 10 );
218+ $ length = request () ->input ('length ' , 10 );
229219
230220 return is_numeric ($ length ) ? intval ($ length ) : 10 ;
231221 }
@@ -235,7 +225,7 @@ public function length(): int
235225 */
236226 public function draw (): int
237227 {
238- $ draw = $ this -> request ->input ('draw ' , 0 );
228+ $ draw = request () ->input ('draw ' , 0 );
239229
240230 return is_numeric ($ draw ) ? intval ($ draw ) : 0 ;
241231 }
0 commit comments