@@ -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 |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | * |
20 | 20 | * @return mixed |
21 | 21 | */ |
22 | - public function all($columns = ['*']); |
|
22 | + public function all($columns = [ '*' ]); |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * Get collection of paginated records |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * |
32 | 32 | * @return mixed |
33 | 33 | */ |
34 | - public function paginate(int $perPage = null, $columns = ['*']); |
|
34 | + public function paginate(int $perPage = null, $columns = [ '*' ]); |
|
35 | 35 | |
36 | 36 | /** |
37 | 37 | * @param int|null $perPage |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @return mixed |
43 | 43 | */ |
44 | - public function simplePaginate(int $perPage = null, $columns = ['*']); |
|
44 | + public function simplePaginate(int $perPage = null, $columns = [ '*' ]); |
|
45 | 45 | |
46 | 46 | /** |
47 | 47 | * Get single or multiple records by their primary ids |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @return mixed |
55 | 55 | */ |
56 | - public function find($id, $columns = ['*']); |
|
56 | + public function find($id, $columns = [ '*' ]); |
|
57 | 57 | |
58 | 58 | /** |
59 | 59 | * @param $field |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return mixed |
66 | 66 | */ |
67 | - public function findByField($field, $value = null, $columns = ['*']); |
|
67 | + public function findByField($field, $value = null, $columns = [ '*' ]); |
|
68 | 68 | |
69 | 69 | /** |
70 | 70 | * Count results of repository |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @return int |
77 | 77 | */ |
78 | - public function count($columns = ['*']): int; |
|
78 | + public function count($columns = [ '*' ]): int; |
|
79 | 79 | |
80 | 80 | /** |
81 | 81 | * Execute the query and get the first result. |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @return mixed |
88 | 88 | */ |
89 | - public function first($columns = ['*']): ?Model; |
|
89 | + public function first($columns = [ '*' ]): ?Model; |
|
90 | 90 | |
91 | 91 | /** |
92 | 92 | * @param array $attributes |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @return Model|null |
97 | 97 | */ |
98 | - public function create(array $attributes = []): ?Model; |
|
98 | + public function create(array $attributes = [ ]): ?Model; |
|
99 | 99 | |
100 | 100 | /** |
101 | 101 | * @param mixed $model |
@@ -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 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | /** |
13 | 13 | * {@inheritDoc} |
14 | 14 | */ |
15 | - public function all($columns = ['*']) |
|
15 | + public function all($columns = [ '*' ]) |
|
16 | 16 | { |
17 | 17 | return parent::all( |
18 | 18 | $this->getColumnNames($columns) |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * {@inheritDoc} |
24 | 24 | */ |
25 | - public function paginate(int $perPage = null, $columns = ['*']) |
|
25 | + public function paginate(int $perPage = null, $columns = [ '*' ]) |
|
26 | 26 | { |
27 | 27 | return parent::paginate( |
28 | 28 | $perPage, |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | /** |
34 | 34 | * {@inheritDoc} |
35 | 35 | */ |
36 | - public function simplePaginate(int $perPage = null, $columns = ['*']) |
|
36 | + public function simplePaginate(int $perPage = null, $columns = [ '*' ]) |
|
37 | 37 | { |
38 | 38 | return parent::simplePaginate( |
39 | 39 | $perPage, |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | /** |
45 | 45 | * {@inheritDoc} |
46 | 46 | */ |
47 | - public function find($id, $columns = ['*']) |
|
47 | + public function find($id, $columns = [ '*' ]) |
|
48 | 48 | { |
49 | 49 | return parent::find( |
50 | 50 | $id, |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | /** |
56 | 56 | * {@inheritDoc} |
57 | 57 | */ |
58 | - public function findByField($field, $value = null, $columns = ['*']) |
|
58 | + public function findByField($field, $value = null, $columns = [ '*' ]) |
|
59 | 59 | { |
60 | 60 | return parent::findByField( |
61 | 61 | $this->getColumnName($field), |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | /** |
68 | 68 | * {@inheritDoc} |
69 | 69 | */ |
70 | - public function first($columns = ['*']): ?Model |
|
70 | + public function first($columns = [ '*' ]): ?Model |
|
71 | 71 | { |
72 | 72 | return parent::first( |
73 | 73 | $this->getColumnNames($columns) |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | { |
85 | 85 | $model = $model ?? $this->model; |
86 | 86 | |
87 | - return ! strpos($column, '.') |
|
87 | + return !strpos($column, '.') |
|
88 | 88 | ? $this->getSchemaName($model) . '.' . $column |
89 | 89 | : $column; |
90 | 90 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function popCriteria($criteria): self |
84 | 84 | { |
85 | - $this->criteria = $this->criteria->reject(function ($value) use ($criteria) { |
|
85 | + $this->criteria = $this->criteria->reject(function($value) use ($criteria) { |
|
86 | 86 | if (is_object($value) && is_string($criteria)) { |
87 | 87 | return get_class($value) === $criteria; |
88 | 88 | } |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | |
111 | 111 | $criteria = $this->getCriteria(); |
112 | 112 | |
113 | - if (! $criteria) { |
|
113 | + if (!$criteria) { |
|
114 | 114 | return $this; |
115 | 115 | } |
116 | 116 |
@@ -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 | } |
@@ -24,12 +24,12 @@ discard block |
||
24 | 24 | /** |
25 | 25 | * @var array |
26 | 26 | */ |
27 | - protected $queryFilters = []; |
|
27 | + protected $queryFilters = [ ]; |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * @var array |
31 | 31 | */ |
32 | - protected $querySettings = []; |
|
32 | + protected $querySettings = [ ]; |
|
33 | 33 | |
34 | 34 | // /** |
35 | 35 | // * @var array |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @return AbstractFilter |
65 | 65 | */ |
66 | - public function setQueryFilters(array $queryFilters = []): self |
|
66 | + public function setQueryFilters(array $queryFilters = [ ]): self |
|
67 | 67 | { |
68 | - $defaultQueryFilters = config('repositories.filtering.default_filters', []); |
|
68 | + $defaultQueryFilters = config('repositories.filtering.default_filters', [ ]); |
|
69 | 69 | // $this->queryFilters = collect( |
70 | 70 | // array_merge($defaultQueryFilters, $queryFilters) |
71 | 71 | // ); |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @return AbstractFilter |
89 | 89 | */ |
90 | - public function setQuerySettings(array $querySettings = []): self |
|
90 | + public function setQuerySettings(array $querySettings = [ ]): self |
|
91 | 91 | { |
92 | - $defaultQuerySettings = config('repositories.filtering.default_settings', []); |
|
92 | + $defaultQuerySettings = config('repositories.filtering.default_settings', [ ]); |
|
93 | 93 | // $this->querySettings = collect( |
94 | 94 | // array_merge($defaultQuerySettings, $querySettings) |
95 | 95 | // ); |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * |
113 | 113 | * @return array |
114 | 114 | */ |
115 | - public function getInput(array $queryFilters = [], array $request = []): array |
|
115 | + public function getInput(array $queryFilters = [ ], array $request = [ ]): array |
|
116 | 116 | { |
117 | 117 | $queryKeys = array_keys($this->getQuerySettings()); |
118 | 118 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | |
124 | 124 | return array_merge( |
125 | 125 | $this->getQuerySettings(), |
126 | - array_filter($input, function ($value) { |
|
126 | + array_filter($input, function($value) { |
|
127 | 127 | return $value !== null; |
128 | 128 | }) |
129 | 129 | ); |
@@ -135,13 +135,13 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @return RepositoryInterface |
137 | 137 | */ |
138 | - public function pushFilters(RepositoryInterface $repository, array $input = []): RepositoryInterface |
|
138 | + public function pushFilters(RepositoryInterface $repository, array $input = [ ]): RepositoryInterface |
|
139 | 139 | { |
140 | 140 | foreach ($this->getQueryFilters() as $filter) { |
141 | - if (isset($input[$filter['queryParameter']])) { |
|
141 | + if (isset($input[ $filter[ 'queryParameter' ] ])) { |
|
142 | 142 | $repository = $repository->pushCriteria( |
143 | - new $filter['uses']( |
|
144 | - $input[$filter['queryParameter']] |
|
143 | + new $filter[ 'uses' ]( |
|
144 | + $input[ $filter[ 'queryParameter' ] ] |
|
145 | 145 | ) |
146 | 146 | ); |
147 | 147 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | */ |
208 | 208 | public function paginate(int $perPage = null) |
209 | 209 | { |
210 | - if (! $perPage) { |
|
210 | + if (!$perPage) { |
|
211 | 211 | $perPage = config('repositories.pagination.per_page'); |
212 | 212 | } |
213 | 213 |