Completed
Push — master ( 0440a4...ed2db0 )
by Gino
01:30
created
models/ModelAbstract.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
103 103
      */
104 104
     protected function queryDisplayEmpty(Builder $query, array $options)
105 105
     {
106
-        if (empty($options['displayEmpty'])) {
106
+        if (empty($options[ 'displayEmpty' ])) {
107 107
             $query
108 108
                 ->having('posts_count', '>', 0);
109 109
         }
@@ -117,11 +117,11 @@  discard block
 block discarded – undo
117 117
      */
118 118
     protected function queryPostSlug(Builder $query, array $options)
119 119
     {
120
-        if (!empty($options['post'])) {
120
+        if (!empty($options[ 'post' ])) {
121 121
             $query->whereHas(
122 122
                 'posts',
123
-                static function ($query) use ($options) {
124
-                    ModelAbstract::whereTranslatableProperty($query, 'slug', $options['post']);
123
+                static function($query) use ($options) {
124
+                    ModelAbstract::whereTranslatableProperty($query, 'slug', $options[ 'post' ]);
125 125
                 }
126 126
             );
127 127
         }
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
      */
136 136
     private function queryLimit(Builder $query, array $options)
137 137
     {
138
-        if (!empty($options['limit'])) {
139
-            $query->take($options['limit']);
138
+        if (!empty($options[ 'limit' ])) {
139
+            $query->take($options[ 'limit' ]);
140 140
         }
141 141
     }
142 142
 
@@ -148,11 +148,11 @@  discard block
 block discarded – undo
148 148
      */
149 149
     private function queryOrderBy(Builder $query, array $options): ?string
150 150
     {
151
-        if (!empty($options['sort']) && \array_key_exists($options['sort'], static::$sortingOptions)) {
152
-            if ($options['sort'] === 'random') {
151
+        if (!empty($options[ 'sort' ]) && \array_key_exists($options[ 'sort' ], static::$sortingOptions)) {
152
+            if ($options[ 'sort' ] === 'random') {
153 153
                 $query->inRandomOrder();
154 154
             } else {
155
-                list($sortField, $sortDirection) = explode(' ', $options['sort']);
155
+                list($sortField, $sortDirection) = explode(' ', $options[ 'sort' ]);
156 156
 
157 157
                 $query->orderBy($sortField, $sortDirection);
158 158
 
@@ -171,10 +171,10 @@  discard block
 block discarded – undo
171 171
      */
172 172
     protected function withRelation(Builder $query, array $options)
173 173
     {
174
-        if (!empty($options['fetchPosts'])) {
174
+        if (!empty($options[ 'fetchPosts' ])) {
175 175
             $query->with(
176 176
                 [
177
-                    'posts' => static function (HasMany $query) use ($options) {
177
+                    'posts' => static function(HasMany $query) use ($options) {
178 178
                         $query->isPublished();
179 179
 
180 180
                         self::handleExceptions($query->getQuery(), $options);
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 
186 186
         $query->withCount(
187 187
             [
188
-                'posts' => static function ($query) use ($options) {
188
+                'posts' => static function($query) use ($options) {
189 189
                     $query->isPublished();
190 190
 
191 191
                     self::handleExceptions($query, $options);
@@ -213,16 +213,16 @@  discard block
 block discarded – undo
213 213
      */
214 214
     protected static function handleExceptions(Builder $query, array $options)
215 215
     {
216
-        if (!empty($options['includeCategories'])) {
217
-            PostListFiltersTrait::handleInclusionsByCategory($query, $options['includeCategories']);
216
+        if (!empty($options[ 'includeCategories' ])) {
217
+            PostListFiltersTrait::handleInclusionsByCategory($query, $options[ 'includeCategories' ]);
218 218
         }
219 219
 
220
-        if (!empty($options['exceptPosts'])) {
221
-            PostListFiltersTrait::handleExceptionsByPost($query, $options['exceptPosts']);
220
+        if (!empty($options[ 'exceptPosts' ])) {
221
+            PostListFiltersTrait::handleExceptionsByPost($query, $options[ 'exceptPosts' ]);
222 222
         }
223 223
 
224
-        if (!empty($options['exceptCategories'])) {
225
-            PostListFiltersTrait::handleExceptionsByCategory($query, $options['exceptCategories']);
224
+        if (!empty($options[ 'exceptCategories' ])) {
225
+            PostListFiltersTrait::handleExceptionsByCategory($query, $options[ 'exceptCategories' ]);
226 226
         }
227 227
     }
228 228
 }
Please login to merge, or discard this patch.