@@ -23,12 +23,12 @@ discard block |
||
| 23 | 23 | /** |
| 24 | 24 | * @var array |
| 25 | 25 | */ |
| 26 | - protected $queryFilters = []; |
|
| 26 | + protected $queryFilters = [ ]; |
|
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * @var array |
| 30 | 30 | */ |
| 31 | - protected $querySettings = []; |
|
| 31 | + protected $querySettings = [ ]; |
|
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | 34 | * AbstractFilter constructor. |
@@ -55,9 +55,9 @@ discard block |
||
| 55 | 55 | * |
| 56 | 56 | * @return AbstractFilter |
| 57 | 57 | */ |
| 58 | - public function setQueryFilters(array $queryFilters = []): self |
|
| 58 | + public function setQueryFilters(array $queryFilters = [ ]): self |
|
| 59 | 59 | { |
| 60 | - $defaultQueryFilters = config('repositories.filtering.default_filters', []); |
|
| 60 | + $defaultQueryFilters = config('repositories.filtering.default_filters', [ ]); |
|
| 61 | 61 | |
| 62 | 62 | $this->queryFilters = array_merge($defaultQueryFilters, $queryFilters); |
| 63 | 63 | |
@@ -77,9 +77,9 @@ discard block |
||
| 77 | 77 | * |
| 78 | 78 | * @return AbstractFilter |
| 79 | 79 | */ |
| 80 | - public function setQuerySettings(array $querySettings = []): self |
|
| 80 | + public function setQuerySettings(array $querySettings = [ ]): self |
|
| 81 | 81 | { |
| 82 | - $defaultQuerySettings = config('repositories.filtering.default_settings', []); |
|
| 82 | + $defaultQuerySettings = config('repositories.filtering.default_settings', [ ]); |
|
| 83 | 83 | $this->querySettings = array_merge($defaultQuerySettings, $querySettings); |
| 84 | 84 | |
| 85 | 85 | return $this; |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | * |
| 100 | 100 | * @return array |
| 101 | 101 | */ |
| 102 | - public function getInput(array $queryFilters = [], array $request = []): array |
|
| 102 | + public function getInput(array $queryFilters = [ ], array $request = [ ]): array |
|
| 103 | 103 | { |
| 104 | 104 | $queryKeys = array_keys($this->getQuerySettings()); |
| 105 | 105 | |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | return array_merge( |
| 112 | 112 | $this->getQuerySettings(), |
| 113 | - array_filter($input, function ($value) { |
|
| 113 | + array_filter($input, function($value) { |
|
| 114 | 114 | return $value !== null; |
| 115 | 115 | }) |
| 116 | 116 | ); |
@@ -122,13 +122,13 @@ discard block |
||
| 122 | 122 | * |
| 123 | 123 | * @return RepositoryInterface |
| 124 | 124 | */ |
| 125 | - public function pushFilters(RepositoryInterface $repository, array $input = []): RepositoryInterface |
|
| 125 | + public function pushFilters(RepositoryInterface $repository, array $input = [ ]): RepositoryInterface |
|
| 126 | 126 | { |
| 127 | 127 | foreach ($this->getQueryFilters() as $filter) { |
| 128 | - if (isset($input[$filter['queryParameter']])) { |
|
| 128 | + if (isset($input[ $filter[ 'queryParameter' ] ])) { |
|
| 129 | 129 | $repository = $repository->pushCriteria( |
| 130 | - new $filter['uses']( |
|
| 131 | - $input[$filter['queryParameter']] |
|
| 130 | + new $filter[ 'uses' ]( |
|
| 131 | + $input[ $filter[ 'queryParameter' ] ] |
|
| 132 | 132 | ) |
| 133 | 133 | ); |
| 134 | 134 | } |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | */ |
| 195 | 195 | public function paginate(int $perPage = null) |
| 196 | 196 | { |
| 197 | - if (! $perPage) { |
|
| 197 | + if (!$perPage) { |
|
| 198 | 198 | $perPage = config('repositories.filtering.default_settings.per_page'); |
| 199 | 199 | } |
| 200 | 200 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | public function apply($model, RepositoryInterface $repository): Builder |
| 62 | 62 | { |
| 63 | - if (! empty($this->attributes) && \is_array($this->attributes)) { |
|
| 63 | + if (!empty($this->attributes) && \is_array($this->attributes)) { |
|
| 64 | 64 | foreach ($this->attributes as $column => $value) { |
| 65 | 65 | $model = $this->applyFilter($model, $column, $value); |
| 66 | 66 | } |
@@ -80,6 +80,6 @@ discard block |
||
| 80 | 80 | { |
| 81 | 81 | |
| 82 | 82 | |
| 83 | - dd([$column, $value]); |
|
| 83 | + dd([ $column, $value ]); |
|
| 84 | 84 | } |
| 85 | 85 | } |
@@ -44,12 +44,12 @@ discard block |
||
| 44 | 44 | public function setOrderByParameters($orderBy): void |
| 45 | 45 | { |
| 46 | 46 | |
| 47 | - [$column, $direction] = explode(',', $orderBy); |
|
| 47 | + [ $column, $direction ] = explode(',', $orderBy); |
|
| 48 | 48 | |
| 49 | 49 | $this->column = $column; |
| 50 | 50 | $this->direction = $direction ?? 'asc'; |
| 51 | 51 | |
| 52 | - if (! \in_array($this->direction, ['asc', 'desc'])) { |
|
| 52 | + if (!\in_array($this->direction, [ 'asc', 'desc' ])) { |
|
| 53 | 53 | $this->direction = 'asc'; |
| 54 | 54 | } |
| 55 | 55 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | return $model; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - if (! preg_match($this->allowedToContain, $this->column)) { |
|
| 71 | + if (!preg_match($this->allowedToContain, $this->column)) { |
|
| 72 | 72 | throw new ValidationException('OrderBy query parameter contains illegal characters.'); |
| 73 | 73 | } |
| 74 | 74 | |