Completed
Push — master ( 28c3ac...3c408f )
by Scott
04:28
created
formwidgets/OptionsInventories.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,11 +28,11 @@
 block discarded – undo
28 28
     public function prepareVars()
29 29
     {
30 30
         if ($this->model->exists) {
31
-            $this->vars['options'] = $this->model->options()->with('values')->get()->toArray();
32
-            $this->vars['inventories'] = $this->model->inventories()->get()->toArray();
31
+            $this->vars[ 'options' ] = $this->model->options()->with('values')->get()->toArray();
32
+            $this->vars[ 'inventories' ] = $this->model->inventories()->get()->toArray();
33 33
         } else {
34
-            $this->vars['options'] = [];
35
-            $this->vars['inventories'] = [];
34
+            $this->vars[ 'options' ] = [ ];
35
+            $this->vars[ 'inventories' ] = [ ];
36 36
         }
37 37
     }
38 38
 
Please login to merge, or discard this patch.
models/Option.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
     /**
16 16
      * @var array Guarded fields
17 17
      */
18
-    protected $guarded = ['*'];
18
+    protected $guarded = [ '*' ];
19 19
 
20 20
     /**
21 21
      * @var array Fillable fields
Please login to merge, or discard this patch.
models/OptionValue.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
     /**
16 16
      * @var array Guarded fields
17 17
      */
18
-    protected $guarded = ['*'];
18
+    protected $guarded = [ '*' ];
19 19
 
20 20
     /**
21 21
      * @var array Fillable fields
Please login to merge, or discard this patch.
models/Product.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
     /**
33 33
      * @var array Guarded fields
34 34
      */
35
-    protected $guarded = ['*'];
35
+    protected $guarded = [ '*' ];
36 36
 
37 37
     /**
38 38
      * @var array Fillable fields
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
     public function saveBasePrice()
140 140
     {
141 141
         Price::updateOrCreate(
142
-            ['product_id' => $this->id, 'discount_id' => null],
143
-            ['price' => $this->base_price]
142
+            [ 'product_id' => $this->id, 'discount_id' => null ],
143
+            [ 'price' => $this->base_price ]
144 144
         );
145 145
     }
146 146
 
@@ -169,8 +169,8 @@  discard block
 block discarded – undo
169 169
     {
170 170
         $data = $this->getOriginalPurgeValue('optionsInventories');
171 171
 
172
-        if (is_array($data['options'])) {
173
-            $options = $this->saveRelatedOptions($data['options']);
172
+        if (is_array($data[ 'options' ])) {
173
+            $options = $this->saveRelatedOptions($data[ 'options' ]);
174 174
         }
175 175
     }
176 176
 
@@ -182,18 +182,18 @@  discard block
 block discarded – undo
182 182
      */
183 183
     protected function saveRelatedOptions(array $options) {
184 184
         foreach ($options as &$option) {
185
-            $model = $option['id'] !== null
186
-                ? Option::firstOrNew(['id' => $option['id']])
185
+            $model = $option[ 'id' ] !== null
186
+                ? Option::firstOrNew([ 'id' => $option[ 'id' ] ])
187 187
                 : new Option;
188 188
 
189 189
             $model->product_id = $this->id;
190 190
             $model->fill($option);
191 191
             $model->save();
192 192
 
193
-            $option['id'] = $model->id;
193
+            $option[ 'id' ] = $model->id;
194 194
 
195
-            if (is_array($option['values'])) {
196
-                $this->saveRelatedOptionValues($model, $option['values']);
195
+            if (is_array($option[ 'values' ])) {
196
+                $this->saveRelatedOptionValues($model, $option[ 'values' ]);
197 197
             }
198 198
         }
199 199
 
@@ -209,8 +209,8 @@  discard block
 block discarded – undo
209 209
      */
210 210
     protected function saveRelatedOptionValues(Option $option, array $values) {
211 211
         foreach ($values as $value) {
212
-            $model = $value['id'] !== null
213
-                ? OptionValue::firstOrNew(['id' => $value['id']])
212
+            $model = $value[ 'id' ] !== null
213
+                ? OptionValue::firstOrNew([ 'id' => $value[ 'id' ] ])
214 214
                 : new OptionValue;
215 215
 
216 216
             $model->option_id = $option->id;
@@ -247,21 +247,21 @@  discard block
 block discarded – undo
247 247
      */
248 248
     public static function syncAllInheritedCategories()
249 249
     {
250
-        Queue::push(function ($job) {
251
-            $data = [];
250
+        Queue::push(function($job) {
251
+            $data = [ ];
252 252
             $products = Product::with('categories')->get();
253 253
             $categoryTree = Category::getParentCategoryIds();
254 254
 
255 255
             foreach ($products as $product) {
256
-                $inheritedCategoryIds = [];
256
+                $inheritedCategoryIds = [ ];
257 257
                 foreach ($product->categories as $category) {
258 258
                     if (array_key_exists($category->id, $categoryTree)) {
259
-                        $inheritedCategoryIds = array_merge($inheritedCategoryIds, $categoryTree[$category->id]);
259
+                        $inheritedCategoryIds = array_merge($inheritedCategoryIds, $categoryTree[ $category->id ]);
260 260
                     }
261 261
                 }
262 262
 
263 263
                 foreach (array_unique($inheritedCategoryIds) as $categoryId) {
264
-                    $data[] = [
264
+                    $data[ ] = [
265 265
                         'category_id' => $categoryId,
266 266
                         'product_id' => $product->id,
267 267
                         'is_inherited' => 1,
@@ -284,11 +284,11 @@  discard block
 block discarded – undo
284 284
      */
285 285
     public function syncInheritedCategories()
286 286
     {
287
-        $data = [];
287
+        $data = [ ];
288 288
         $categoryIds = $this->categories()->lists('id');
289 289
         $parentIds = Category::isParentOf($categoryIds)->lists('id');
290 290
         foreach ($parentIds as $parentId) {
291
-            $data[] = [
291
+            $data[ ] = [
292 292
                 'category_id' => $parentId,
293 293
                 'product_id' => $this->id,
294 294
                 'is_inherited' => true,
Please login to merge, or discard this patch.