@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | /** |
21 | 21 | * @var array |
22 | 22 | */ |
23 | - public static $sortingOptions = []; |
|
23 | + public static $sortingOptions = [ ]; |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Sets the URL attribute with a URL to this object |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @return mixed |
55 | 55 | */ |
56 | - public function scopeListFrontend(Builder $query, array $options = []) |
|
56 | + public function scopeListFrontend(Builder $query, array $options = [ ]) |
|
57 | 57 | { |
58 | 58 | $this->withRelation($query, $options); |
59 | 59 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | */ |
104 | 104 | private function queryDisplayEmpty(Builder $query, array $options) |
105 | 105 | { |
106 | - if (empty($options['displayEmpty'])) { |
|
106 | + if (empty($options[ 'displayEmpty' ])) { |
|
107 | 107 | $query->having('posts_count', '>', 0); |
108 | 108 | } |
109 | 109 | } |
@@ -116,11 +116,11 @@ discard block |
||
116 | 116 | */ |
117 | 117 | private function queryPostSlug(Builder $query, array $options) |
118 | 118 | { |
119 | - if (!empty($options['post'])) { |
|
119 | + if (!empty($options[ 'post' ])) { |
|
120 | 120 | $query->whereHas( |
121 | 121 | 'posts', |
122 | - static function ($query) use ($options) { |
|
123 | - ModelAbstract::whereTranslatableProperty($query, 'slug', $options['post']); |
|
122 | + static function($query) use ($options) { |
|
123 | + ModelAbstract::whereTranslatableProperty($query, 'slug', $options[ 'post' ]); |
|
124 | 124 | } |
125 | 125 | ); |
126 | 126 | } |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | */ |
135 | 135 | private function queryLimit(Builder $query, array $options) |
136 | 136 | { |
137 | - if (!empty($options['limit'])) { |
|
138 | - $query->take($options['limit']); |
|
137 | + if (!empty($options[ 'limit' ])) { |
|
138 | + $query->take($options[ 'limit' ]); |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
@@ -147,11 +147,11 @@ discard block |
||
147 | 147 | */ |
148 | 148 | private function queryOrderBy(Builder $query, array $options) |
149 | 149 | { |
150 | - if (!empty($options['sort']) && \array_key_exists($options['sort'], static::$sortingOptions)) { |
|
151 | - if ($options['sort'] === 'random') { |
|
150 | + if (!empty($options[ 'sort' ]) && \array_key_exists($options[ 'sort' ], static::$sortingOptions)) { |
|
151 | + if ($options[ 'sort' ] === 'random') { |
|
152 | 152 | $query->inRandomOrder(); |
153 | 153 | } else { |
154 | - list($sortField, $sortDirection) = explode(' ', $options['sort']); |
|
154 | + list($sortField, $sortDirection) = explode(' ', $options[ 'sort' ]); |
|
155 | 155 | |
156 | 156 | $query->orderBy($sortField, $sortDirection); |
157 | 157 | } |
@@ -166,10 +166,10 @@ discard block |
||
166 | 166 | */ |
167 | 167 | private function withRelation(Builder $query, array $options) |
168 | 168 | { |
169 | - if (!empty($options['fetchPosts'])) { |
|
169 | + if (!empty($options[ 'fetchPosts' ])) { |
|
170 | 170 | $query->with( |
171 | 171 | [ |
172 | - 'posts' => function (HasMany $query) use ($options) { |
|
172 | + 'posts' => function(HasMany $query) use ($options) { |
|
173 | 173 | $query->isPublished(); |
174 | 174 | |
175 | 175 | $this->handleExceptions($query->getQuery(), $options); |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | |
181 | 181 | $query->withCount( |
182 | 182 | [ |
183 | - 'posts' => function ($query) use ($options) { |
|
183 | + 'posts' => function($query) use ($options) { |
|
184 | 184 | $query->isPublished(); |
185 | 185 | |
186 | 186 | $this->handleExceptions($query, $options); |
@@ -203,12 +203,12 @@ discard block |
||
203 | 203 | */ |
204 | 204 | private function handleExceptions(Builder $query, array $options) |
205 | 205 | { |
206 | - if (!empty($options['exceptPosts'])) { |
|
207 | - PostListExceptionsTrait::handleExceptionsByPost($query, $options['exceptPosts']); |
|
206 | + if (!empty($options[ 'exceptPosts' ])) { |
|
207 | + PostListExceptionsTrait::handleExceptionsByPost($query, $options[ 'exceptPosts' ]); |
|
208 | 208 | } |
209 | 209 | |
210 | - if (!empty($options['exceptCategories'])) { |
|
211 | - PostListExceptionsTrait::handleExceptionsByCategory($query, $options['exceptCategories']); |
|
210 | + if (!empty($options[ 'exceptCategories' ])) { |
|
211 | + PostListExceptionsTrait::handleExceptionsByCategory($query, $options[ 'exceptCategories' ]); |
|
212 | 212 | } |
213 | 213 | } |
214 | 214 | } |