@@ -28,7 +28,7 @@ |
||
| 28 | 28 | } else { |
| 29 | 29 | $publishPath = base_path('config/repositories.php'); |
| 30 | 30 | } |
| 31 | - $this->publishes([$configPath => $publishPath], 'config'); |
|
| 31 | + $this->publishes([ $configPath => $publishPath ], 'config'); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -43,12 +43,12 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function setOrderByParameters($orderBy): void |
| 45 | 45 | { |
| 46 | - [$column, $direction] = explode(',', $orderBy); |
|
| 46 | + [ $column, $direction ] = explode(',', $orderBy); |
|
| 47 | 47 | |
| 48 | 48 | $this->column = $column; |
| 49 | 49 | $this->direction = $direction ?? 'asc'; |
| 50 | 50 | |
| 51 | - if (! \in_array($this->direction, ['asc', 'desc'])) { |
|
| 51 | + if (!\in_array($this->direction, [ 'asc', 'desc' ])) { |
|
| 52 | 52 | $this->direction = 'asc'; |
| 53 | 53 | } |
| 54 | 54 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | return $model; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - if (! preg_match($this->allowedToContain, $this->column)) { |
|
| 70 | + if (!preg_match($this->allowedToContain, $this->column)) { |
|
| 71 | 71 | throw new ValidationException('OrderBy query parameter contains illegal characters.'); |
| 72 | 72 | } |
| 73 | 73 | |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | public function getColumnNames(array $columns, $model = null): array |
| 31 | 31 | { |
| 32 | - return array_map(function ($column) use ($model) { |
|
| 32 | + return array_map(function($column) use ($model) { |
|
| 33 | 33 | return $this->getColumnName($column, $model); |
| 34 | 34 | }, $columns); |
| 35 | 35 | } |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | { |
| 89 | 89 | $model = $this->app->make($this->getModelClassName()); |
| 90 | 90 | |
| 91 | - if (! $model instanceof Model) { |
|
| 91 | + if (!$model instanceof Model) { |
|
| 92 | 92 | throw new RepositoryException( |
| 93 | 93 | "Class {$this->getModelClassName()} must be an instance of " . Model::class |
| 94 | 94 | ); |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * |
| 158 | 158 | * @return EloquentBuilder[]|\Illuminate\Database\Eloquent\Collection|Model[]|mixed |
| 159 | 159 | */ |
| 160 | - public function all($columns = ['*']) |
|
| 160 | + public function all($columns = [ '*' ]) |
|
| 161 | 161 | { |
| 162 | 162 | $this->applyCriteria() |
| 163 | 163 | ->applyScope(); |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | * |
| 184 | 184 | * @return EloquentBuilder[]|\Illuminate\Database\Eloquent\Collection|Model[]|mixed |
| 185 | 185 | */ |
| 186 | - public function get($columns = ['*']) |
|
| 186 | + public function get($columns = [ '*' ]) |
|
| 187 | 187 | { |
| 188 | 188 | return $this->all($columns); |
| 189 | 189 | } |
@@ -198,9 +198,9 @@ discard block |
||
| 198 | 198 | * |
| 199 | 199 | * @return mixed |
| 200 | 200 | */ |
| 201 | - public function paginate(int $perPage = null, $columns = ['*']) |
|
| 201 | + public function paginate(int $perPage = null, $columns = [ '*' ]) |
|
| 202 | 202 | { |
| 203 | - return $this->getPaginator($perPage, $columns, function ($perPage, $columns) { |
|
| 203 | + return $this->getPaginator($perPage, $columns, function($perPage, $columns) { |
|
| 204 | 204 | return $this->model |
| 205 | 205 | ->paginate($perPage, $columns) |
| 206 | 206 | ->appends(app('request')->query()); |
@@ -215,9 +215,9 @@ discard block |
||
| 215 | 215 | * |
| 216 | 216 | * @return mixed |
| 217 | 217 | */ |
| 218 | - public function simplePaginate(int $perPage = null, $columns = ['*']) |
|
| 218 | + public function simplePaginate(int $perPage = null, $columns = [ '*' ]) |
|
| 219 | 219 | { |
| 220 | - return $this->getPaginator($perPage, $columns, function ($perPage, $columns) { |
|
| 220 | + return $this->getPaginator($perPage, $columns, function($perPage, $columns) { |
|
| 221 | 221 | return $this->model |
| 222 | 222 | ->simplePaginate($perPage, $columns) |
| 223 | 223 | ->appends(app('request')->query()); |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | * |
| 234 | 234 | * @return mixed |
| 235 | 235 | */ |
| 236 | - protected function getPaginator(int $perPage = null, $columns = ['*'], callable $callback = null) |
|
| 236 | + protected function getPaginator(int $perPage = null, $columns = [ '*' ], callable $callback = null) |
|
| 237 | 237 | { |
| 238 | 238 | $this->applyCriteria() |
| 239 | 239 | ->applyScope(); |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | * |
| 257 | 257 | * @return mixed |
| 258 | 258 | */ |
| 259 | - public function find($id, $columns = ['*']) |
|
| 259 | + public function find($id, $columns = [ '*' ]) |
|
| 260 | 260 | { |
| 261 | 261 | $this->applyCriteria() |
| 262 | 262 | ->applyScope(); |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | * |
| 278 | 278 | * @return mixed |
| 279 | 279 | */ |
| 280 | - public function findByField($field, $value = null, $columns = ['*']) |
|
| 280 | + public function findByField($field, $value = null, $columns = [ '*' ]) |
|
| 281 | 281 | { |
| 282 | 282 | $this->applyCriteria() |
| 283 | 283 | ->applyScope(); |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | * |
| 301 | 301 | * @return int |
| 302 | 302 | */ |
| 303 | - public function count($columns = ['*']): int |
|
| 303 | + public function count($columns = [ '*' ]): int |
|
| 304 | 304 | { |
| 305 | 305 | $this->applyCriteria() |
| 306 | 306 | ->applyScope(); |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | * |
| 322 | 322 | * @return mixed |
| 323 | 323 | */ |
| 324 | - public function first($columns = ['*']): ?Model |
|
| 324 | + public function first($columns = [ '*' ]): ?Model |
|
| 325 | 325 | { |
| 326 | 326 | $this->applyCriteria() |
| 327 | 327 | ->applyScope(); |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | * |
| 341 | 341 | * @return Model|null |
| 342 | 342 | */ |
| 343 | - public function create(array $attributes = []): ?Model |
|
| 343 | + public function create(array $attributes = [ ]): ?Model |
|
| 344 | 344 | { |
| 345 | 345 | $model = $this->model->create($attributes); |
| 346 | 346 | $this->clearModel(); |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | { |
| 362 | 362 | $this->applyScope(); |
| 363 | 363 | |
| 364 | - if (! $model instanceof Model) { |
|
| 364 | + if (!$model instanceof Model) { |
|
| 365 | 365 | $model = $this->model->findOrFail($model); |
| 366 | 366 | } |
| 367 | 367 | |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | { |
| 384 | 384 | $this->applyScope(); |
| 385 | 385 | |
| 386 | - if (! $model instanceof Model) { |
|
| 386 | + if (!$model instanceof Model) { |
|
| 387 | 387 | $model = $this->find($model); |
| 388 | 388 | } |
| 389 | 389 | |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | public function getWith(): array |
| 17 | 17 | { |
| 18 | - return $this->getPreloadables()['with'] ?? []; |
|
| 18 | + return $this->getPreloadables()[ 'with' ] ?? [ ]; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -23,6 +23,6 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | public function getWithCount(): array |
| 25 | 25 | { |
| 26 | - return $this->getPreloadables()['withCount'] ?? []; |
|
| 26 | + return $this->getPreloadables()[ 'withCount' ] ?? [ ]; |
|
| 27 | 27 | } |
| 28 | 28 | } |
@@ -17,11 +17,11 @@ discard block |
||
| 17 | 17 | * |
| 18 | 18 | * @return array |
| 19 | 19 | */ |
| 20 | - public function only($keys, array $input = []): array |
|
| 20 | + public function only($keys, array $input = [ ]): array |
|
| 21 | 21 | { |
| 22 | 22 | $keys = \is_array($keys) ? $keys : \func_get_args(); |
| 23 | 23 | |
| 24 | - $output = []; |
|
| 24 | + $output = [ ]; |
|
| 25 | 25 | |
| 26 | 26 | foreach ($keys as $key) { |
| 27 | 27 | Arr::set($output, $key, data_get($input, $key)); |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * |
| 39 | 39 | * @return array |
| 40 | 40 | */ |
| 41 | - public function except($keys, array $input = []): array |
|
| 41 | + public function except($keys, array $input = [ ]): array |
|
| 42 | 42 | { |
| 43 | 43 | $keys = \is_array($keys) ? $keys : \func_get_args(); |
| 44 | 44 | |
@@ -55,12 +55,12 @@ discard block |
||
| 55 | 55 | * |
| 56 | 56 | * @return bool |
| 57 | 57 | */ |
| 58 | - public function exists($key, array $input = []): bool |
|
| 58 | + public function exists($key, array $input = [ ]): bool |
|
| 59 | 59 | { |
| 60 | 60 | $keys = \is_array($key) ? $key : \func_get_args(); |
| 61 | 61 | |
| 62 | 62 | foreach ($keys as $value) { |
| 63 | - if (! Arr::has($input, $value)) { |
|
| 63 | + if (!Arr::has($input, $value)) { |
|
| 64 | 64 | return false; |
| 65 | 65 | } |
| 66 | 66 | } |
@@ -77,8 +77,8 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | public function getQueryParams(array $queryFilters): array |
| 79 | 79 | { |
| 80 | - return array_map(function ($param) { |
|
| 81 | - return $param['queryParameter']; |
|
| 80 | + return array_map(function($param) { |
|
| 81 | + return $param[ 'queryParameter' ]; |
|
| 82 | 82 | }, $queryFilters); |
| 83 | 83 | } |
| 84 | 84 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | public function apply($model, RepositoryInterface $repository): Builder |
| 44 | 44 | { |
| 45 | - if (! empty($this->attributes) && \is_array($this->attributes)) { |
|
| 45 | + if (!empty($this->attributes) && \is_array($this->attributes)) { |
|
| 46 | 46 | foreach ($this->attributes as $parameter => $value) { |
| 47 | 47 | $model = $this->applyFilter($model, $parameter, $value); |
| 48 | 48 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | $parser = (new FilterQueryParser($parameter, $value))->parse(); |
| 66 | 66 | $relation = $parser->getRelation(); |
| 67 | 67 | |
| 68 | - if ($relation && ! $this->modelHasRelation($model->getModel(), $relation)) { |
|
| 68 | + if ($relation && !$this->modelHasRelation($model->getModel(), $relation)) { |
|
| 69 | 69 | throw new RepositoryException('Trying to filter by non existent relation.'); |
| 70 | 70 | } |
| 71 | 71 | |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | if ($relation) { |
| 78 | 78 | $model = $model->whereHas( |
| 79 | 79 | $relation, |
| 80 | - function ($query) use ($column, $dataType, $expression, $valueToSearch): void { |
|
| 80 | + function($query) use ($column, $dataType, $expression, $valueToSearch): void { |
|
| 81 | 81 | $this->applyDataTypeFilter($query, $column, $dataType, $expression, $valueToSearch); |
| 82 | 82 | } |
| 83 | 83 | ); |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | $namespace = 'Noitran\Repositories\Criteria\Support\\'; |
| 118 | 118 | $criteria = $namespace . ucfirst($dataType) . 'Criteria'; |
| 119 | 119 | |
| 120 | - if (! class_exists($criteria)) { |
|
| 120 | + if (!class_exists($criteria)) { |
|
| 121 | 121 | $defaultCriteria = $namespace . 'DefaultCriteria'; |
| 122 | 122 | |
| 123 | 123 | return new $defaultCriteria(); |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | /** @var Invoice $invoice */ |
| 67 | 67 | $loan = $invoice->getLoan(); |
| 68 | 68 | |
| 69 | - if (! $this->checkerService->isCalculationAllowed($invoice, $overdueDays)) { |
|
| 69 | + if (!$this->checkerService->isCalculationAllowed($invoice, $overdueDays)) { |
|
| 70 | 70 | return false; |
| 71 | 71 | } |
| 72 | 72 | $disableLoanZeroInterestSetting = $this |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | $disableLoanZeroInterest = ($disableLoanZeroInterestSetting > 0 && $overdueDays >= $disableLoanZeroInterestSetting + 1); |
| 77 | 77 | |
| 78 | - if (! $disableLoanZeroInterest) { |
|
| 78 | + if (!$disableLoanZeroInterest) { |
|
| 79 | 79 | return false; |
| 80 | 80 | } |
| 81 | 81 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @return mixed |
| 23 | 23 | */ |
| 24 | - public function all($columns = ['*']); |
|
| 24 | + public function all($columns = [ '*' ]); |
|
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * Get collection of paginated records. |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * |
| 34 | 34 | * @return mixed |
| 35 | 35 | */ |
| 36 | - public function paginate(int $perPage = null, $columns = ['*']); |
|
| 36 | + public function paginate(int $perPage = null, $columns = [ '*' ]); |
|
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | 39 | * @param int|null $perPage |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * |
| 44 | 44 | * @return mixed |
| 45 | 45 | */ |
| 46 | - public function simplePaginate(int $perPage = null, $columns = ['*']); |
|
| 46 | + public function simplePaginate(int $perPage = null, $columns = [ '*' ]); |
|
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | 49 | * Get single or multiple records by their primary ids. |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * |
| 56 | 56 | * @return mixed |
| 57 | 57 | */ |
| 58 | - public function find($id, $columns = ['*']); |
|
| 58 | + public function find($id, $columns = [ '*' ]); |
|
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | 61 | * @param $field |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | * |
| 67 | 67 | * @return mixed |
| 68 | 68 | */ |
| 69 | - public function findByField($field, $value = null, $columns = ['*']); |
|
| 69 | + public function findByField($field, $value = null, $columns = [ '*' ]); |
|
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | 72 | * Count results of repository. |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * |
| 78 | 78 | * @return int |
| 79 | 79 | */ |
| 80 | - public function count($columns = ['*']): int; |
|
| 80 | + public function count($columns = [ '*' ]): int; |
|
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | 83 | * Execute the query and get the first result. |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | * |
| 89 | 89 | * @return mixed |
| 90 | 90 | */ |
| 91 | - public function first($columns = ['*']): ?Model; |
|
| 91 | + public function first($columns = [ '*' ]): ?Model; |
|
| 92 | 92 | |
| 93 | 93 | /** |
| 94 | 94 | * @param array $attributes |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | * |
| 98 | 98 | * @return Model|null |
| 99 | 99 | */ |
| 100 | - public function create(array $attributes = []): ?Model; |
|
| 100 | + public function create(array $attributes = [ ]): ?Model; |
|
| 101 | 101 | |
| 102 | 102 | /** |
| 103 | 103 | * @param mixed $model |