@@ -41,8 +41,8 @@ |
||
41 | 41 | */ |
42 | 42 | public function rowValue($attribute, $template) |
43 | 43 | { |
44 | - if (! empty($template)) { |
|
45 | - if (! is_callable($template) && Arr::get($this->data, $template)) { |
|
44 | + if (!empty($template)) { |
|
45 | + if (!is_callable($template) && Arr::get($this->data, $template)) { |
|
46 | 46 | $this->data[$attribute] = Arr::get($this->data, $template); |
47 | 47 | } else { |
48 | 48 | $this->data[$attribute] = Helper::compileContent($template, $this->data, $this->row); |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (! function_exists('datatables')) { |
|
3 | +if (!function_exists('datatables')) { |
|
4 | 4 | /** |
5 | 5 | * Helper to make a new DataTable instance from source. |
6 | 6 | * Or return the factory if source is not set. |
@@ -45,10 +45,10 @@ discard block |
||
45 | 45 | foreach ($engines as $engine => $class) { |
46 | 46 | $engine = Str::camel($engine); |
47 | 47 | |
48 | - if (! method_exists(DataTables::class, $engine) && ! DataTables::hasMacro($engine)) { |
|
48 | + if (!method_exists(DataTables::class, $engine) && !DataTables::hasMacro($engine)) { |
|
49 | 49 | DataTables::macro($engine, function () use ($class) { |
50 | 50 | $canCreate = [$class, 'canCreate']; |
51 | - if (is_callable($canCreate) && ! call_user_func_array($canCreate, func_get_args())) { |
|
51 | + if (is_callable($canCreate) && !call_user_func_array($canCreate, func_get_args())) { |
|
52 | 52 | throw new \InvalidArgumentException(); |
53 | 53 | } |
54 | 54 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | protected function setupAssets() |
70 | 70 | { |
71 | - $this->mergeConfigFrom($config = __DIR__.'/config/datatables.php', 'datatables'); |
|
71 | + $this->mergeConfigFrom($config = __DIR__ . '/config/datatables.php', 'datatables'); |
|
72 | 72 | |
73 | 73 | if ($this->app->runningInConsole()) { |
74 | 74 | $this->publishes([$config => config_path('datatables.php')], 'datatables'); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (! function_exists('config_path')) { |
|
3 | +if (!function_exists('config_path')) { |
|
4 | 4 | /** |
5 | 5 | * Get the configuration path. |
6 | 6 | * |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | */ |
10 | 10 | function config_path($path = '') |
11 | 11 | { |
12 | - return app()->basePath().'/config'.($path ? '/'.$path : $path); |
|
12 | + return app()->basePath() . '/config' . ($path ? '/' . $path : $path); |
|
13 | 13 | } |
14 | 14 | } |
15 | 15 | |
16 | -if (! function_exists('public_path')) { |
|
16 | +if (!function_exists('public_path')) { |
|
17 | 17 | /** |
18 | 18 | * Return the path to public dir. |
19 | 19 | * |
@@ -22,6 +22,6 @@ discard block |
||
22 | 22 | */ |
23 | 23 | function public_path($path = null) |
24 | 24 | { |
25 | - return rtrim(app()->basePath('public/'.$path), '/'); |
|
25 | + return rtrim(app()->basePath('public/' . $path), '/'); |
|
26 | 26 | } |
27 | 27 | } |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | |
185 | 185 | if ($formatter instanceof Formatter) { |
186 | 186 | foreach ((array) $columns as $column) { |
187 | - $this->addColumn($column.'_formatted', $formatter); |
|
187 | + $this->addColumn($column . '_formatted', $formatter); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | return $this; |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | if (is_callable($formatter)) { |
194 | 194 | foreach ((array) $columns as $column) { |
195 | 195 | $this->addColumn( |
196 | - $column.'_formatted', |
|
196 | + $column . '_formatted', |
|
197 | 197 | function ($row) use ($column, $formatter) { |
198 | 198 | return $formatter(data_get($row, $column), $row); |
199 | 199 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | |
206 | 206 | foreach ((array) $columns as $column) { |
207 | 207 | $this->addColumn( |
208 | - $column.'_formatted', |
|
208 | + $column . '_formatted', |
|
209 | 209 | function ($row) use ($column) { |
210 | 210 | return data_get($row, $column); |
211 | 211 | } |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | public function editColumn($name, $content): static |
268 | 268 | { |
269 | 269 | if ($this->editOnlySelectedColumns) { |
270 | - if (! count($this->request->columns()) || in_array($name, Arr::pluck($this->request->columns(), 'name'))) { |
|
270 | + if (!count($this->request->columns()) || in_array($name, Arr::pluck($this->request->columns(), 'name'))) { |
|
271 | 271 | $this->columnDef['edit'][] = ['name' => $name, 'content' => $content]; |
272 | 272 | } |
273 | 273 | } else { |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | * @param string|array $whitelist |
527 | 527 | * @return $this |
528 | 528 | */ |
529 | - public function whitelist(array|string $whitelist = '*'): static |
|
529 | + public function whitelist(array | string $whitelist = '*'): static |
|
530 | 530 | { |
531 | 531 | $this->columnDef['whitelist'] = $whitelist; |
532 | 532 | |
@@ -645,7 +645,7 @@ discard block |
||
645 | 645 | */ |
646 | 646 | public function pushToBlacklist($column): static |
647 | 647 | { |
648 | - if (! $this->isBlacklisted($column)) { |
|
648 | + if (!$this->isBlacklisted($column)) { |
|
649 | 649 | $this->columnDef['blacklist'][] = $column; |
650 | 650 | } |
651 | 651 | |
@@ -865,7 +865,7 @@ discard block |
||
865 | 865 | */ |
866 | 866 | protected function paginate(): void |
867 | 867 | { |
868 | - if ($this->request->isPaginationable() && ! $this->skipPaging) { |
|
868 | + if ($this->request->isPaginationable() && !$this->skipPaging) { |
|
869 | 869 | $this->paging(); |
870 | 870 | } |
871 | 871 | } |
@@ -980,7 +980,7 @@ discard block |
||
980 | 980 | $error = $this->config->get('datatables.error'); |
981 | 981 | $debug = $this->config->get('app.debug'); |
982 | 982 | |
983 | - if ($error === 'throw' || (! $error && ! $debug)) { |
|
983 | + if ($error === 'throw' || (!$error && !$debug)) { |
|
984 | 984 | throw $exception; |
985 | 985 | } |
986 | 986 | |
@@ -991,7 +991,7 @@ discard block |
||
991 | 991 | 'recordsTotal' => $this->totalRecords, |
992 | 992 | 'recordsFiltered' => 0, |
993 | 993 | 'data' => [], |
994 | - 'error' => $error ? __($error) : "Exception Message:\n\n".$exception->getMessage(), |
|
994 | + 'error' => $error ? __($error) : "Exception Message:\n\n" . $exception->getMessage(), |
|
995 | 995 | ]); |
996 | 996 | } |
997 | 997 | |
@@ -1029,7 +1029,7 @@ discard block |
||
1029 | 1029 | protected function setupKeyword(string $value): string |
1030 | 1030 | { |
1031 | 1031 | if ($this->config->isSmartSearch()) { |
1032 | - $keyword = '%'.$value.'%'; |
|
1032 | + $keyword = '%' . $value . '%'; |
|
1033 | 1033 | if ($this->config->isWildcard()) { |
1034 | 1034 | $keyword = Helper::wildcardLikeString($value); |
1035 | 1035 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | } |
82 | 82 | } |
83 | 83 | |
84 | - throw new Exception('No available engine for '.get_class($source)); |
|
84 | + throw new Exception('No available engine for ' . get_class($source)); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | */ |
173 | 173 | public function getHtmlBuilder() |
174 | 174 | { |
175 | - if (! class_exists(Builder::class)) { |
|
175 | + if (!class_exists(Builder::class)) { |
|
176 | 176 | throw new Exception('Please install yajra/laravel-datatables-html to be able to use this function.'); |
177 | 177 | } |
178 | 178 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | */ |
189 | 189 | public function validateDataTable(string $engine, string $parent): void |
190 | 190 | { |
191 | - if (! ($engine == $parent || is_subclass_of($engine, $parent))) { |
|
191 | + if (!($engine == $parent || is_subclass_of($engine, $parent))) { |
|
192 | 192 | $this->throwInvalidEngineException($engine, $parent); |
193 | 193 | } |
194 | 194 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @param array|object $row |
171 | 171 | * @return array |
172 | 172 | */ |
173 | - protected function editColumns(array $data, object|array $row): array |
|
173 | + protected function editColumns(array $data, object | array $row): array |
|
174 | 174 | { |
175 | 175 | foreach ($this->editColumns as $value) { |
176 | 176 | $value['content'] = Helper::compileContent($value['content'], $data, $row); |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * @param array|object $row |
188 | 188 | * @return array |
189 | 189 | */ |
190 | - protected function setupRowVariables(array $data, object|array $row): array |
|
190 | + protected function setupRowVariables(array $data, object | array $row): array |
|
191 | 191 | { |
192 | 192 | $processor = new RowProcessor($data, $row); |
193 | 193 | |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | { |
294 | 294 | $arrayDot = array_filter(Arr::dot($row)); |
295 | 295 | foreach ($arrayDot as $key => $value) { |
296 | - if (! in_array($key, $this->rawColumns)) { |
|
296 | + if (!in_array($key, $this->rawColumns)) { |
|
297 | 297 | $arrayDot[$key] = (is_string($value) || $value instanceof Htmlable) ? e($value) : $value; |
298 | 298 | } |
299 | 299 | } |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | */ |
142 | 142 | public static function canCreate($source): bool |
143 | 143 | { |
144 | - return $source instanceof QueryBuilder && ! ($source instanceof EloquentBuilder); |
|
144 | + return $source instanceof QueryBuilder && !($source instanceof EloquentBuilder); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | */ |
183 | 183 | public function prepareQuery(): static |
184 | 184 | { |
185 | - if (! $this->prepared) { |
|
185 | + if (!$this->prepared) { |
|
186 | 186 | $this->totalRecords = $this->totalCount(); |
187 | 187 | |
188 | 188 | $this->filterRecords(); |
@@ -216,10 +216,10 @@ discard block |
||
216 | 216 | |
217 | 217 | if ($this->isComplexQuery($builder)) { |
218 | 218 | $builder->select(DB::raw('1 as dt_row_count')); |
219 | - if ($this->ignoreSelectInCountQuery || ! $this->isComplexQuery($builder)) { |
|
219 | + if ($this->ignoreSelectInCountQuery || !$this->isComplexQuery($builder)) { |
|
220 | 220 | return $this->getConnection() |
221 | 221 | ->query() |
222 | - ->fromRaw('('.$builder->toSql().') count_row_table') |
|
222 | + ->fromRaw('(' . $builder->toSql() . ') count_row_table') |
|
223 | 223 | ->setBindings($builder->getBindings()); |
224 | 224 | } |
225 | 225 | |
@@ -227,13 +227,13 @@ discard block |
||
227 | 227 | |
228 | 228 | return $this->getConnection() |
229 | 229 | ->query() |
230 | - ->fromRaw('('.$builder->toSql().') count_row_table') |
|
230 | + ->fromRaw('(' . $builder->toSql() . ') count_row_table') |
|
231 | 231 | ->setBindings($builder->getBindings()); |
232 | 232 | } |
233 | 233 | |
234 | 234 | $row_count = $this->wrap('row_count'); |
235 | 235 | $builder->select($this->getConnection()->raw("'1' as {$row_count}")); |
236 | - if (! $this->keepSelectBindings) { |
|
236 | + if (!$this->keepSelectBindings) { |
|
237 | 237 | $builder->setBindings([], 'select'); |
238 | 238 | } |
239 | 239 | |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | continue; |
320 | 320 | } |
321 | 321 | |
322 | - if (! $this->request->isColumnSearchable($index) || $this->isBlacklisted($column) && ! $this->hasFilterColumn($column)) { |
|
322 | + if (!$this->request->isColumnSearchable($index) || $this->isBlacklisted($column) && !$this->hasFilterColumn($column)) { |
|
323 | 323 | continue; |
324 | 324 | } |
325 | 325 | |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | */ |
411 | 411 | protected function getBaseQueryBuilder($instance = null) |
412 | 412 | { |
413 | - if (! $instance) { |
|
413 | + if (!$instance) { |
|
414 | 414 | $instance = $this->query; |
415 | 415 | } |
416 | 416 | |
@@ -472,20 +472,20 @@ discard block |
||
472 | 472 | |
473 | 473 | switch ($this->getConnection()->getDriverName()) { |
474 | 474 | case 'oracle': |
475 | - $sql = ! $this->config->isCaseInsensitive() |
|
476 | - ? 'REGEXP_LIKE( '.$column.' , ? )' |
|
477 | - : 'REGEXP_LIKE( LOWER('.$column.') , ?, \'i\' )'; |
|
475 | + $sql = !$this->config->isCaseInsensitive() |
|
476 | + ? 'REGEXP_LIKE( ' . $column . ' , ? )' |
|
477 | + : 'REGEXP_LIKE( LOWER(' . $column . ') , ?, \'i\' )'; |
|
478 | 478 | break; |
479 | 479 | |
480 | 480 | case 'pgsql': |
481 | 481 | $column = $this->castColumn($column); |
482 | - $sql = ! $this->config->isCaseInsensitive() ? $column.' ~ ?' : $column.' ~* ? '; |
|
482 | + $sql = !$this->config->isCaseInsensitive() ? $column . ' ~ ?' : $column . ' ~* ? '; |
|
483 | 483 | break; |
484 | 484 | |
485 | 485 | default: |
486 | - $sql = ! $this->config->isCaseInsensitive() |
|
487 | - ? $column.' REGEXP ?' |
|
488 | - : 'LOWER('.$column.') REGEXP ?'; |
|
486 | + $sql = !$this->config->isCaseInsensitive() |
|
487 | + ? $column . ' REGEXP ?' |
|
488 | + : 'LOWER(' . $column . ') REGEXP ?'; |
|
489 | 489 | $keyword = Str::lower($keyword); |
490 | 490 | } |
491 | 491 | |
@@ -502,9 +502,9 @@ discard block |
||
502 | 502 | { |
503 | 503 | switch ($this->getConnection()->getDriverName()) { |
504 | 504 | case 'pgsql': |
505 | - return 'CAST('.$column.' as TEXT)'; |
|
505 | + return 'CAST(' . $column . ' as TEXT)'; |
|
506 | 506 | case 'firebird': |
507 | - return 'CAST('.$column.' as VARCHAR(255))'; |
|
507 | + return 'CAST(' . $column . ' as VARCHAR(255))'; |
|
508 | 508 | default: |
509 | 509 | return $column; |
510 | 510 | } |
@@ -523,13 +523,13 @@ discard block |
||
523 | 523 | { |
524 | 524 | $column = $this->addTablePrefix($query, $column); |
525 | 525 | $column = $this->castColumn($column); |
526 | - $sql = $column.' LIKE ?'; |
|
526 | + $sql = $column . ' LIKE ?'; |
|
527 | 527 | |
528 | 528 | if ($this->config->isCaseInsensitive()) { |
529 | - $sql = 'LOWER('.$column.') LIKE ?'; |
|
529 | + $sql = 'LOWER(' . $column . ') LIKE ?'; |
|
530 | 530 | } |
531 | 531 | |
532 | - $query->{$boolean.'WhereRaw'}($sql, [$this->prepareKeyword($keyword)]); |
|
532 | + $query->{$boolean . 'WhereRaw'}($sql, [$this->prepareKeyword($keyword)]); |
|
533 | 533 | } |
534 | 534 | |
535 | 535 | /** |
@@ -542,17 +542,17 @@ discard block |
||
542 | 542 | */ |
543 | 543 | protected function addTablePrefix($query, string $column): string |
544 | 544 | { |
545 | - if (! str_contains($column, '.')) { |
|
545 | + if (!str_contains($column, '.')) { |
|
546 | 546 | $q = $this->getBaseQueryBuilder($query); |
547 | 547 | $from = $q->from; |
548 | 548 | |
549 | 549 | /** @phpstan-ignore-next-line */ |
550 | - if (! $from instanceof Expression) { |
|
550 | + if (!$from instanceof Expression) { |
|
551 | 551 | if (str_contains($from, ' as ')) { |
552 | 552 | $from = explode(' as ', $from)[1]; |
553 | 553 | } |
554 | 554 | |
555 | - $column = $from.'.'.$column; |
|
555 | + $column = $from . '.' . $column; |
|
556 | 556 | } |
557 | 557 | } |
558 | 558 | |
@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | return $orderable; |
749 | 749 | }) |
750 | 750 | ->reject(function ($orderable) { |
751 | - return $this->isBlacklisted($orderable['name']) && ! $this->hasOrderColumn($orderable['name']); |
|
751 | + return $this->isBlacklisted($orderable['name']) && !$this->hasOrderColumn($orderable['name']); |
|
752 | 752 | }) |
753 | 753 | ->each(function ($orderable) { |
754 | 754 | $column = $this->resolveRelationColumn($orderable['name']); |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | $this->applyOrderColumn($column, $orderable); |
760 | 760 | } else { |
761 | 761 | $nullsLastSql = $this->getNullsLastSql($column, $orderable['direction']); |
762 | - $normalSql = $this->wrap($column).' '.$orderable['direction']; |
|
762 | + $normalSql = $this->wrap($column) . ' ' . $orderable['direction']; |
|
763 | 763 | $sql = $this->nullsLast ? $nullsLastSql : $normalSql; |
764 | 764 | $this->query->orderByRaw($sql); |
765 | 765 | } |
@@ -841,7 +841,7 @@ discard block |
||
841 | 841 | }) |
842 | 842 | ->filter() |
843 | 843 | ->reject(function ($column) { |
844 | - return $this->isBlacklisted($column) && ! $this->hasFilterColumn($column); |
|
844 | + return $this->isBlacklisted($column) && !$this->hasFilterColumn($column); |
|
845 | 845 | }) |
846 | 846 | ->each(function ($column) use ($keyword, $query) { |
847 | 847 | if ($this->hasFilterColumn($column)) { |
@@ -966,10 +966,10 @@ discard block |
||
966 | 966 | public function enableScoutSearch(string $model, int $max_hits = 1000): static |
967 | 967 | { |
968 | 968 | $scout_model = new $model; |
969 | - if (! class_exists($model) || ! ($scout_model instanceof Model)) { |
|
969 | + if (!class_exists($model) || !($scout_model instanceof Model)) { |
|
970 | 970 | throw new \Exception("$model must be an Eloquent Model."); |
971 | 971 | } |
972 | - if (! method_exists($scout_model, 'searchableAs') || ! method_exists($scout_model, 'getScoutKeyName')) { |
|
972 | + if (!method_exists($scout_model, 'searchableAs') || !method_exists($scout_model, 'getScoutKeyName')) { |
|
973 | 973 | throw new \Exception("$model must use the Searchable trait."); |
974 | 974 | } |
975 | 975 | |
@@ -1058,7 +1058,7 @@ discard block |
||
1058 | 1058 | |
1059 | 1059 | switch ($driverName) { |
1060 | 1060 | case 'mysql': |
1061 | - $this->query->orderByRaw("FIELD($keyName, ".$orderedKeys->implode(',').')'); |
|
1061 | + $this->query->orderByRaw("FIELD($keyName, " . $orderedKeys->implode(',') . ')'); |
|
1062 | 1062 | |
1063 | 1063 | return true; |
1064 | 1064 | |
@@ -1106,7 +1106,7 @@ discard block |
||
1106 | 1106 | */ |
1107 | 1107 | protected function performScoutSearch(string $searchKeyword, mixed $searchFilters = []): array |
1108 | 1108 | { |
1109 | - if (! class_exists('\Laravel\Scout\EngineManager')) { |
|
1109 | + if (!class_exists('\Laravel\Scout\EngineManager')) { |
|
1110 | 1110 | throw new \Exception('Laravel Scout is not installed.'); |
1111 | 1111 | } |
1112 | 1112 | $engine = app(\Laravel\Scout\EngineManager::class)->engine(); |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | continue; |
110 | 110 | } |
111 | 111 | |
112 | - if (! $this->request->isColumnSearchable($i) || $this->isBlacklisted($column)) { |
|
112 | + if (!$this->request->isColumnSearchable($i) || $this->isBlacklisted($column)) { |
|
113 | 113 | continue; |
114 | 114 | } |
115 | 115 | |
@@ -125,14 +125,14 @@ discard block |
||
125 | 125 | |
126 | 126 | if ($this->config->isCaseInsensitive()) { |
127 | 127 | if ($regex) { |
128 | - return preg_match('/'.$keyword.'/i', $value) == 1; |
|
128 | + return preg_match('/' . $keyword . '/i', $value) == 1; |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | return str_contains(Str::lower($value), Str::lower($keyword)); |
132 | 132 | } |
133 | 133 | |
134 | 134 | if ($regex) { |
135 | - return preg_match('/'.$keyword.'/', $value) == 1; |
|
135 | + return preg_match('/' . $keyword . '/', $value) == 1; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | return str_contains($value, $keyword); |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | foreach ($this->request->searchableColumnIndex() as $index) { |
248 | 248 | $column = $this->getColumnName($index); |
249 | 249 | $value = Arr::get($data, $column); |
250 | - if (! is_string($value)) { |
|
250 | + if (!is_string($value)) { |
|
251 | 251 | continue; |
252 | 252 | } else { |
253 | 253 | $value = $this->config->isCaseInsensitive() ? Str::lower($value) : $value; |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | protected function defaultOrdering(): void |
271 | 271 | { |
272 | 272 | $criteria = $this->request->orderableColumns(); |
273 | - if (! empty($criteria)) { |
|
273 | + if (!empty($criteria)) { |
|
274 | 274 | $sorter = $this->getSorter($criteria); |
275 | 275 | |
276 | 276 | $this->collection = $this->collection |