Completed
Pull Request — master (#2770)
by Arjay
22s
created
src/Utilities/Request.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
      */
88 88
     public function orderableColumns()
89 89
     {
90
-        if (! $this->isOrderable()) {
90
+        if (!$this->isOrderable()) {
91 91
             return [];
92 92
         }
93 93
 
@@ -241,8 +241,8 @@  discard block
 block discarded – undo
241 241
      */
242 242
     public function isPaginationable(): bool
243 243
     {
244
-        return ! is_null($this->request->input('start')) &&
245
-            ! is_null($this->request->input('length')) &&
244
+        return !is_null($this->request->input('start')) &&
245
+            !is_null($this->request->input('length')) &&
246 246
             $this->request->input('length') != -1;
247 247
     }
248 248
 
Please login to merge, or discard this patch.
src/Utilities/Helper.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
         }
92 92
 
93 93
         ob_start() && extract($data, EXTR_SKIP);
94
-        eval('?>'.app('blade.compiler')->compileString($str));
94
+        eval('?>' . app('blade.compiler')->compileString($str));
95 95
         $str = ob_get_contents();
96 96
         ob_end_clean();
97 97
 
@@ -153,8 +153,8 @@  discard block
 block discarded – undo
153 153
      */
154 154
     public static function getOrMethod($method)
155 155
     {
156
-        if (! Str::contains(Str::lower($method), 'or')) {
157
-            return 'or'.ucfirst($method);
156
+        if (!Str::contains(Str::lower($method), 'or')) {
157
+            return 'or' . ucfirst($method);
158 158
         }
159 159
 
160 160
         return $method;
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 
318 318
         if (count($chars) > 0) {
319 319
             foreach ($chars as $char) {
320
-                $wild .= $char.$wildcard;
320
+                $wild .= $char . $wildcard;
321 321
             }
322 322
         }
323 323
 
Please login to merge, or discard this patch.
src/DataTables.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
             }
79 79
         }
80 80
 
81
-        throw new Exception('No available engine for '.get_class($source));
81
+        throw new Exception('No available engine for ' . get_class($source));
82 82
     }
83 83
 
84 84
     /**
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
      */
146 146
     public function getHtmlBuilder()
147 147
     {
148
-        if (! class_exists('\Yajra\DataTables\Html\Builder')) {
148
+        if (!class_exists('\Yajra\DataTables\Html\Builder')) {
149 149
             throw new Exception('Please install yajra/laravel-datatables-html to be able to use this function.');
150 150
         }
151 151
 
Please login to merge, or discard this patch.
src/DataTablesServiceProvider.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -45,10 +45,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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');
Please login to merge, or discard this patch.
src/DataTableAbstract.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -190,13 +190,13 @@  discard block
 block discarded – undo
190 190
 
191 191
         if ($formatter instanceof Formatter) {
192 192
             foreach ((array) $columns as $column) {
193
-                $this->addColumn($column.'_formatted', $formatter);
193
+                $this->addColumn($column . '_formatted', $formatter);
194 194
             }
195 195
 
196 196
             return $this;
197 197
         }
198 198
 
199
-        throw new Exception('$formatter must be an instance of '.Formatter::class);
199
+        throw new Exception('$formatter must be an instance of ' . Formatter::class);
200 200
     }
201 201
 
202 202
     /**
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
      */
586 586
     public function pushToBlacklist($column): self
587 587
     {
588
-        if (! $this->isBlacklisted($column)) {
588
+        if (!$this->isBlacklisted($column)) {
589 589
             $this->columnDef['blacklist'][] = $column;
590 590
         }
591 591
 
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
      */
797 797
     protected function paginate(): void
798 798
     {
799
-        if ($this->request->isPaginationable() && ! $this->skipPaging) {
799
+        if ($this->request->isPaginationable() && !$this->skipPaging) {
800 800
             $this->paging();
801 801
         }
802 802
     }
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
         $error = $this->config->get('datatables.error');
910 910
         $debug = $this->config->get('app.debug');
911 911
 
912
-        if ($error === 'throw' || (! $error && ! $debug)) {
912
+        if ($error === 'throw' || (!$error && !$debug)) {
913 913
             throw $exception;
914 914
         }
915 915
 
@@ -920,7 +920,7 @@  discard block
 block discarded – undo
920 920
             'recordsTotal' => $this->totalRecords,
921 921
             'recordsFiltered' => 0,
922 922
             'data' => [],
923
-            'error' => $error ? __($error) : "Exception Message:\n\n".$exception->getMessage(),
923
+            'error' => $error ? __($error) : "Exception Message:\n\n" . $exception->getMessage(),
924 924
         ]);
925 925
     }
926 926
 
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
     protected function setupKeyword(string $value): string
959 959
     {
960 960
         if ($this->config->isSmartSearch()) {
961
-            $keyword = '%'.$value.'%';
961
+            $keyword = '%' . $value . '%';
962 962
             if ($this->config->isWildcard()) {
963 963
                 $keyword = Helper::wildcardLikeString($value);
964 964
             }
Please login to merge, or discard this patch.
src/lumen.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/EloquentDataTable.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -100,12 +100,12 @@  discard block
 block discarded – undo
100 100
         }
101 101
 
102 102
         if ($this->isMorphRelation($relation)) {
103
-            $query->{$boolean.'WhereHasMorph'}($relation, '*',
103
+            $query->{$boolean . 'WhereHasMorph'}($relation, '*',
104 104
                 function (EloquentBuilder $query) use ($newColumn, $keyword) {
105 105
                     parent::compileQuerySearch($query, $newColumn, $keyword, '');
106 106
                 });
107 107
         } else {
108
-            $query->{$boolean.'WhereHas'}($relation, function (EloquentBuilder $query) use ($newColumn, $keyword) {
108
+            $query->{$boolean . 'WhereHas'}($relation, function (EloquentBuilder $query) use ($newColumn, $keyword) {
109 109
                 parent::compileQuerySearch($query, $newColumn, $keyword, '');
110 110
             });
111 111
         }
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
      */
120 120
     protected function isNotEagerLoaded($relation)
121 121
     {
122
-        return ! $relation
123
-            || ! array_key_exists($relation, $this->query->getEagerLoads())
122
+        return !$relation
123
+            || !array_key_exists($relation, $this->query->getEagerLoads())
124 124
             || $relation === $this->query->getModel()->getTable();
125 125
     }
126 126
 
@@ -189,24 +189,24 @@  discard block
 block discarded – undo
189 189
                     $related = $model->getRelated();
190 190
                     $table = $related->getTable();
191 191
                     $tablePK = $related->getForeignKey();
192
-                    $foreign = $pivot.'.'.$tablePK;
192
+                    $foreign = $pivot . '.' . $tablePK;
193 193
                     $other = $related->getQualifiedKeyName();
194 194
 
195
-                    $lastQuery->addSelect($table.'.'.$relationColumn);
195
+                    $lastQuery->addSelect($table . '.' . $relationColumn);
196 196
                     $this->performJoin($table, $foreign, $other);
197 197
 
198 198
                     break;
199 199
 
200 200
                 case $model instanceof HasOneThrough:
201 201
                     $pivot = explode('.', $model->getQualifiedParentKeyName())[0]; // extract pivot table from key
202
-                    $pivotPK = $pivot.'.'.$model->getLocalKeyName();
202
+                    $pivotPK = $pivot . '.' . $model->getLocalKeyName();
203 203
                     $pivotFK = $model->getQualifiedLocalKeyName();
204 204
                     $this->performJoin($pivot, $pivotPK, $pivotFK);
205 205
 
206 206
                     $related = $model->getRelated();
207 207
                     $table = $related->getTable();
208 208
                     $tablePK = $related->getForeignKey();
209
-                    $foreign = $pivot.'.'.$tablePK;
209
+                    $foreign = $pivot . '.' . $tablePK;
210 210
                     $other = $related->getQualifiedKeyName();
211 211
 
212 212
                     break;
@@ -224,13 +224,13 @@  discard block
 block discarded – undo
224 224
                     break;
225 225
 
226 226
                 default:
227
-                    throw new Exception('Relation '.get_class($model).' is not yet supported.');
227
+                    throw new Exception('Relation ' . get_class($model) . ' is not yet supported.');
228 228
             }
229 229
             $this->performJoin($table, $foreign, $other);
230 230
             $lastQuery = $model->getQuery();
231 231
         }
232 232
 
233
-        return $table.'.'.$relationColumn;
233
+        return $table . '.' . $relationColumn;
234 234
     }
235 235
 
236 236
     /**
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
             $joins[] = $join->table;
250 250
         }
251 251
 
252
-        if (! in_array($table, $joins)) {
252
+        if (!in_array($table, $joins)) {
253 253
             $this->getBaseQueryBuilder()->join($table, $foreign, '=', $other, $type);
254 254
         }
255 255
     }
Please login to merge, or discard this patch.
src/QueryDataTable.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
      */
120 120
     protected function prepareQuery(): void
121 121
     {
122
-        if (! $this->prepared) {
122
+        if (!$this->prepared) {
123 123
             $this->totalRecords = $this->totalCount();
124 124
 
125 125
             if ($this->totalRecords) {
@@ -168,14 +168,14 @@  discard block
 block discarded – undo
168 168
         $builder = clone $this->query;
169 169
 
170 170
         if ($this->isComplexQuery($builder)) {
171
-            $table = $this->connection->raw('('.$builder->toSql().') count_row_table');
171
+            $table = $this->connection->raw('(' . $builder->toSql() . ') count_row_table');
172 172
 
173 173
             return $this->connection->table($table)->setBindings($builder->getBindings());
174 174
         }
175 175
 
176 176
         $row_count = $this->wrap('row_count');
177 177
         $builder->select($this->connection->raw("'1' as {$row_count}"));
178
-        if (! $this->keepSelectBindings) {
178
+        if (!$this->keepSelectBindings) {
179 179
             $builder->setBindings([], 'select');
180 180
         }
181 181
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
         foreach ($columns as $index => $column) {
252 252
             $column = $this->getColumnName($index);
253 253
 
254
-            if (! $this->request->isColumnSearchable($index) || $this->isBlacklisted($column) && ! $this->hasFilterColumn($column)) {
254
+            if (!$this->request->isColumnSearchable($index) || $this->isBlacklisted($column) && !$this->hasFilterColumn($column)) {
255 255
                 continue;
256 256
             }
257 257
 
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
      */
332 332
     protected function getBaseQueryBuilder($instance = null)
333 333
     {
334
-        if (! $instance) {
334
+        if (!$instance) {
335 335
             $instance = $this->query;
336 336
         }
337 337
 
@@ -383,20 +383,20 @@  discard block
 block discarded – undo
383 383
 
384 384
         switch ($this->connection->getDriverName()) {
385 385
             case 'oracle':
386
-                $sql = ! $this->config->isCaseInsensitive()
387
-                    ? 'REGEXP_LIKE( '.$column.' , ? )'
388
-                    : 'REGEXP_LIKE( LOWER('.$column.') , ?, \'i\' )';
386
+                $sql = !$this->config->isCaseInsensitive()
387
+                    ? 'REGEXP_LIKE( ' . $column . ' , ? )'
388
+                    : 'REGEXP_LIKE( LOWER(' . $column . ') , ?, \'i\' )';
389 389
                 break;
390 390
 
391 391
             case 'pgsql':
392 392
                 $column = $this->castColumn($column);
393
-                $sql = ! $this->config->isCaseInsensitive() ? $column.' ~ ?' : $column.' ~* ? ';
393
+                $sql = !$this->config->isCaseInsensitive() ? $column . ' ~ ?' : $column . ' ~* ? ';
394 394
                 break;
395 395
 
396 396
             default:
397
-                $sql = ! $this->config->isCaseInsensitive()
398
-                    ? $column.' REGEXP ?'
399
-                    : 'LOWER('.$column.') REGEXP ?';
397
+                $sql = !$this->config->isCaseInsensitive()
398
+                    ? $column . ' REGEXP ?'
399
+                    : 'LOWER(' . $column . ') REGEXP ?';
400 400
                 $keyword = Str::lower($keyword);
401 401
         }
402 402
 
@@ -413,9 +413,9 @@  discard block
 block discarded – undo
413 413
     {
414 414
         switch ($this->connection->getDriverName()) {
415 415
             case 'pgsql':
416
-                return 'CAST('.$column.' as TEXT)';
416
+                return 'CAST(' . $column . ' as TEXT)';
417 417
             case 'firebird':
418
-                return 'CAST('.$column.' as VARCHAR(255))';
418
+                return 'CAST(' . $column . ' as VARCHAR(255))';
419 419
             default:
420 420
                 return $column;
421 421
         }
@@ -434,13 +434,13 @@  discard block
 block discarded – undo
434 434
     {
435 435
         $column = $this->addTablePrefix($query, $column);
436 436
         $column = $this->castColumn($column);
437
-        $sql = $column.' LIKE ?';
437
+        $sql = $column . ' LIKE ?';
438 438
 
439 439
         if ($this->config->isCaseInsensitive()) {
440
-            $sql = 'LOWER('.$column.') LIKE ?';
440
+            $sql = 'LOWER(' . $column . ') LIKE ?';
441 441
         }
442 442
 
443
-        $query->{$boolean.'WhereRaw'}($sql, [$this->prepareKeyword($keyword)]);
443
+        $query->{$boolean . 'WhereRaw'}($sql, [$this->prepareKeyword($keyword)]);
444 444
     }
445 445
 
446 446
     /**
@@ -453,11 +453,11 @@  discard block
 block discarded – undo
453 453
      */
454 454
     protected function addTablePrefix($query, string $column): string
455 455
     {
456
-        if (! str_contains($column, '.')) {
456
+        if (!str_contains($column, '.')) {
457 457
             $q = $this->getBaseQueryBuilder($query);
458 458
             /** @phpstan-ignore-next-line */
459
-            if (! $q->from instanceof Expression) {
460
-                $column = $q->from.'.'.$column;
459
+            if (!$q->from instanceof Expression) {
460
+                $column = $q->from . '.' . $column;
461 461
             }
462 462
         }
463 463
 
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
                 return $orderable;
671 671
             })
672 672
             ->reject(function ($orderable) {
673
-                return $this->isBlacklisted($orderable['name']) && ! $this->hasOrderColumn($orderable['name']);
673
+                return $this->isBlacklisted($orderable['name']) && !$this->hasOrderColumn($orderable['name']);
674 674
             })
675 675
             ->each(function ($orderable) {
676 676
                 $column = $this->resolveRelationColumn($orderable['name']);
@@ -679,7 +679,7 @@  discard block
 block discarded – undo
679 679
                     $this->applyOrderColumn($column, $orderable);
680 680
                 } else {
681 681
                     $nullsLastSql = $this->getNullsLastSql($column, $orderable['direction']);
682
-                    $normalSql = $this->wrap($column).' '.$orderable['direction'];
682
+                    $normalSql = $this->wrap($column) . ' ' . $orderable['direction'];
683 683
                     $sql = $this->nullsLast ? $nullsLastSql : $normalSql;
684 684
                     $this->query->orderByRaw($sql);
685 685
                 }
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
                     return $this->getColumnName($index);
756 756
                 })
757 757
                 ->reject(function ($column) {
758
-                    return $this->isBlacklisted($column) && ! $this->hasFilterColumn($column);
758
+                    return $this->isBlacklisted($column) && !$this->hasFilterColumn($column);
759 759
                 })
760 760
                 ->each(function ($column) use ($keyword, $query) {
761 761
                     if ($this->hasFilterColumn($column)) {
Please login to merge, or discard this patch.
src/CollectionDataTable.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
      *
23 23
      * @var \Illuminate\Support\Collection|\Illuminate\Http\Resources\Json\JsonResource
24 24
      */
25
-    public Collection|JsonResource $original;
25
+    public Collection | JsonResource $original;
26 26
 
27 27
     /**
28 28
      * The offset of the first record in the full dataset.
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
         for ($i = 0, $c = count($columns); $i < $c; $i++) {
108 108
             $column = $this->getColumnName($i);
109 109
 
110
-            if (! $this->request->isColumnSearchable($i) || $this->isBlacklisted($column)) {
110
+            if (!$this->request->isColumnSearchable($i) || $this->isBlacklisted($column)) {
111 111
                 continue;
112 112
             }
113 113
 
@@ -125,14 +125,14 @@  discard block
 block discarded – undo
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);
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
             foreach ($this->request->searchableColumnIndex() as $index) {
246 246
                 $column = $this->getColumnName($index);
247 247
                 $value = Arr::get($data, $column);
248
-                if (! is_string($value)) {
248
+                if (!is_string($value)) {
249 249
                     continue;
250 250
                 } else {
251 251
                     $value = $this->config->isCaseInsensitive() ? Str::lower($value) : $value;
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
     protected function defaultOrdering(): void
267 267
     {
268 268
         $criteria = $this->request->orderableColumns();
269
-        if (! empty($criteria)) {
269
+        if (!empty($criteria)) {
270 270
             $sorter = $this->getSorter($criteria);
271 271
 
272 272
             $this->collection = $this->collection
Please login to merge, or discard this patch.