Completed
Push — master ( ee5070...a8860f )
by Scott
03:33
created
models/Price.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.
updates/1.0/create_prices_table.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 {
9 9
     public function up()
10 10
     {
11
-        Schema::create('bedard_shop_prices', function (Blueprint $table) {
11
+        Schema::create('bedard_shop_prices', function(Blueprint $table) {
12 12
             $table->engine = 'InnoDB';
13 13
             $table->increments('id');
14 14
             $table->decimal('price', 10, 2)->unsigned();
Please login to merge, or discard this patch.
traits/Timeable.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
      */
13 13
     public static function bootTimeable()
14 14
     {
15
-        static::extend(function ($model) {
15
+        static::extend(function($model) {
16 16
             $model->addFillable('start_at', 'end_at');
17 17
             $model->addDateAttribute('start_at');
18 18
             $model->addDateAttribute('end_at');
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
      */
28 28
     public function scopeIsActive(Builder $query)
29 29
     {
30
-        return $query->where(function ($model) {
30
+        return $query->where(function($model) {
31 31
             return $model->isNotExpired()->isNotUpcoming();
32 32
         });
33 33
     }
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
      */
41 41
     public function scopeIsExpired(Builder $query)
42 42
     {
43
-        return $query->where(function ($model) {
43
+        return $query->where(function($model) {
44 44
             return $model->whereNotNull('end_at')
45 45
                 ->where('end_at', '<=', (string) Carbon::now());
46 46
         });
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      */
55 55
     public function scopeIsUpcoming(Builder $query)
56 56
     {
57
-        return $query->where(function ($model) {
57
+        return $query->where(function($model) {
58 58
             return $model->whereNotNull('start_at')
59 59
                 ->where('start_at', '>', (string) Carbon::now());
60 60
         });
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
      */
69 69
     public function scopeIsNotActive(Builder $query)
70 70
     {
71
-        return $query->where(function ($model) {
72
-            return $model->isExpired()->orWhere(function ($q) {
71
+        return $query->where(function($model) {
72
+            return $model->isExpired()->orWhere(function($q) {
73 73
                 $q->isUpcoming();
74 74
             });
75 75
         });
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      */
84 84
     public function scopeIsNotExpired(Builder $query)
85 85
     {
86
-        return $query->where(function ($model) {
86
+        return $query->where(function($model) {
87 87
             return $model->whereNull('end_at')
88 88
                 ->orWhere('end_at', '>', (string) Carbon::now());
89 89
         });
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
      */
98 98
     public function scopeIsNotUpcoming(Builder $query)
99 99
     {
100
-        return $query->where(function ($model) {
100
+        return $query->where(function($model) {
101 101
             return $model->whereNull('start_at')
102 102
                 ->orWhere('start_at', '<=', (string) Carbon::now());
103 103
         });
Please login to merge, or discard this patch.
models/Product.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
     /**
30 30
      * @var array Guarded fields
31 31
      */
32
-    protected $guarded = ['*'];
32
+    protected $guarded = [ '*' ];
33 33
 
34 34
     /**
35 35
      * @var array Fillable fields
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
     public function saveBasePrice()
126 126
     {
127 127
         Price::updateOrCreate(
128
-            ['product_id' => $this->id, 'discount_id' => null],
129
-            ['price' => $this->base_price]
128
+            [ 'product_id' => $this->id, 'discount_id' => null ],
129
+            [ 'price' => $this->base_price ]
130 130
         );
131 131
     }
132 132
 
@@ -173,21 +173,21 @@  discard block
 block discarded – undo
173 173
      */
174 174
     public static function syncAllInheritedCategories()
175 175
     {
176
-        Queue::push(function ($job) {
177
-            $data = [];
176
+        Queue::push(function($job) {
177
+            $data = [ ];
178 178
             $products = Product::with('categories')->get();
179 179
             $categoryTree = Category::getParentCategoryIds();
180 180
 
181 181
             foreach ($products as $product) {
182
-                $inheritedCategoryIds = [];
182
+                $inheritedCategoryIds = [ ];
183 183
                 foreach ($product->categories as $category) {
184 184
                     if (array_key_exists($category->id, $categoryTree)) {
185
-                        $inheritedCategoryIds = array_merge($inheritedCategoryIds, $categoryTree[$category->id]);
185
+                        $inheritedCategoryIds = array_merge($inheritedCategoryIds, $categoryTree[ $category->id ]);
186 186
                     }
187 187
                 }
188 188
 
189 189
                 foreach (array_unique($inheritedCategoryIds) as $categoryId) {
190
-                    $data[] = [
190
+                    $data[ ] = [
191 191
                         'category_id' => $categoryId,
192 192
                         'product_id' => $product->id,
193 193
                         'is_inherited' => 1,
@@ -210,11 +210,11 @@  discard block
 block discarded – undo
210 210
      */
211 211
     public function syncInheritedCategories(array $categoryIds = null)
212 212
     {
213
-        $data = [];
213
+        $data = [ ];
214 214
         $categoryIds = $this->categories()->lists('id');
215 215
         $parentIds = Category::isParentOf($categoryIds)->lists('id');
216 216
         foreach ($parentIds as $parentId) {
217
-            $data[] = [
217
+            $data[ ] = [
218 218
                 'category_id' => $parentId,
219 219
                 'product_id' => $this->id,
220 220
                 'is_inherited' => true,
Please login to merge, or discard this patch.
controllers/Categories.php 1 patch
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -65,7 +65,6 @@
 block discarded – undo
65 65
     /**
66 66
      * Override the default list delete behavior
67 67
      *
68
-     * @param  \Bedard\Shop\Models\Category $record
69 68
      * @return void
70 69
      */
71 70
     public function overrideListDelete(Category $catgory)
Please login to merge, or discard this patch.
models/Category.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
     /**
36 36
      * @var array Guarded fields
37 37
      */
38
-    protected $guarded = ['*'];
38
+    protected $guarded = [ '*' ];
39 39
 
40 40
     /**
41 41
      * @var array Fillable fields
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
         'products' => [
66 66
             'Bedard\Shop\Models\Product',
67 67
             'table' => 'bedard_shop_category_product',
68
-            'pivot' => ['is_inherited'],
68
+            'pivot' => [ 'is_inherited' ],
69 69
         ],
70 70
     ];
71 71
 
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
     {
118 118
         $categories = self::select('id', 'parent_id')->get();
119 119
 
120
-        $tree = [];
120
+        $tree = [ ];
121 121
         foreach ($categories as $category) {
122
-            $tree[$category->id] = self::walkParentCategories($categories, $category);
122
+            $tree[ $category->id ] = self::walkParentCategories($categories, $category);
123 123
         }
124 124
 
125 125
         return $tree;
@@ -141,10 +141,10 @@  discard block
 block discarded – undo
141 141
                 ->get();
142 142
         }
143 143
 
144
-        $children = [];
144
+        $children = [ ];
145 145
         foreach ($categories as $category) {
146 146
             if ($category->parent_id == $parent) {
147
-                $children[] = $category->id;
147
+                $children[ ] = $category->id;
148 148
                 $children = array_merge($children, self::getChildIds($category->id, $categories));
149 149
             }
150 150
         }
@@ -154,23 +154,23 @@  discard block
 block discarded – undo
154 154
 
155 155
     public static function getParentIds($children, \October\Rain\Database\Collection $categories = null)
156 156
     {
157
-        if (! is_array($children)) {
158
-            $children = [$children];
157
+        if (!is_array($children)) {
158
+            $children = [ $children ];
159 159
         }
160 160
 
161 161
         if ($categories === null) {
162 162
             $categories = self::select('id', 'parent_id')->get();
163 163
         }
164 164
 
165
-        $parents = [];
165
+        $parents = [ ];
166 166
         foreach ($children as $child) {
167
-            $category = $categories->filter(function ($model) use ($child) {
167
+            $category = $categories->filter(function($model) use ($child) {
168 168
                 return $model->id == $child;
169 169
             })->first();
170 170
 
171 171
             while ($category && $category->parent_id) {
172
-                $parents[] = $category->parent_id;
173
-                $category = $categories->filter(function ($model) use ($category) {
172
+                $parents[ ] = $category->parent_id;
173
+                $category = $categories->filter(function($model) use ($category) {
174 174
                     return $model->id == $category->parent_id;
175 175
                 })->first();
176 176
             }
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
      */
251 251
     public function setNullParentId()
252 252
     {
253
-        if (! $this->parent_id) {
253
+        if (!$this->parent_id) {
254 254
             $this->parent_id = null;
255 255
         }
256 256
     }
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
      */
273 273
     public function syncInheritedProductsAfterDelete()
274 274
     {
275
-        if (! $this->dontSyncAfterDelete) {
275
+        if (!$this->dontSyncAfterDelete) {
276 276
             Product::syncAllInheritedCategories();
277 277
         }
278 278
     }
@@ -298,8 +298,8 @@  discard block
 block discarded – undo
298 298
     public static function updateMany(array $categories)
299 299
     {
300 300
         foreach ($categories as $category) {
301
-            $id = $category['id'];
302
-            unset($category['id']);
301
+            $id = $category[ 'id' ];
302
+            unset($category[ 'id' ]);
303 303
             self::whereId($id)->update($category);
304 304
         }
305 305
     }
@@ -312,10 +312,10 @@  discard block
 block discarded – undo
312 312
      * @param  array                                $tree           Tree of parent IDs
313 313
      * @return arrau
314 314
      */
315
-    public static function walkParentCategories($categories, $category, $tree = [])
315
+    public static function walkParentCategories($categories, $category, $tree = [ ])
316 316
     {
317 317
         if ($category && $category->parent_id !== null) {
318
-            $tree[] = $category->parent_id;
318
+            $tree[ ] = $category->parent_id;
319 319
             $tree = array_merge($tree, self::walkParentCategories($categories, $categories->find($category->parent_id)));
320 320
         }
321 321
 
Please login to merge, or discard this patch.
models/Discount.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     /**
44 44
      * @var array Guarded fields
45 45
      */
46
-    protected $guarded = ['*'];
46
+    protected $guarded = [ '*' ];
47 47
 
48 48
     /**
49 49
      * @var array Fillable fields
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
     public function filterFields($fields)
157 157
     {
158 158
         $fields->amount_exact->hidden = $this->is_percentage;
159
-        $fields->amount_percentage->hidden = ! $this->is_percentage;
159
+        $fields->amount_percentage->hidden = !$this->is_percentage;
160 160
     }
161 161
 
162 162
     /**
@@ -168,14 +168,14 @@  discard block
 block discarded – undo
168 168
     {
169 169
         $productIds = $this->products()->lists('id');
170 170
         $categories = $this->categories()
171
-            ->with(['products' => function ($product) {
171
+            ->with([ 'products' => function($product) {
172 172
                 return $product->select('id');
173
-            }])
174
-            ->get(['id']);
173
+            } ])
174
+            ->get([ 'id' ]);
175 175
 
176 176
         foreach ($categories as $category) {
177 177
             foreach ($category->products as $product) {
178
-                $productIds[] = $product->id;
178
+                $productIds[ ] = $product->id;
179 179
             }
180 180
         }
181 181
 
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
      */
190 190
     public function getAmountExactAttribute()
191 191
     {
192
-        return ! $this->is_percentage ? $this->amount : 0;
192
+        return !$this->is_percentage ? $this->amount : 0;
193 193
     }
194 194
 
195 195
     /**
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
     public function savePrices()
211 211
     {
212 212
         $id = $this->id;
213
-        Queue::push(function ($job) use ($id) {
213
+        Queue::push(function($job) use ($id) {
214 214
             $discount = Discount::findOrFail($id);
215 215
             $productIds = $discount->getAllProductIds();
216 216
             $products = Product::whereIn('id', $productIds)->select('id', 'base_price')->get();
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
      */
241 241
     public static function syncAllPrices()
242 242
     {
243
-        $data = [];
243
+        $data = [ ];
244 244
         $discounts = self::isNotExpired()->with('categories.products', 'products')->get();
245 245
         foreach ($discounts as $discount) {
246 246
             $products = $discount->products;
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
             }
250 250
 
251 251
             foreach ($products as $product) {
252
-                $data[] = [
252
+                $data[ ] = [
253 253
                     'discount_id' => $discount->id,
254 254
                     'end_at' => $discount->end_at,
255 255
                     'price' => $discount->calculatePrice($product->base_price),
@@ -266,17 +266,17 @@  discard block
 block discarded – undo
266 266
     public static function syncProductPrice(Product $product, array $categoryIds)
267 267
     {
268 268
         $discounts = self::isNotExpired()
269
-            ->whereHas('products', function ($query) use ($product) {
269
+            ->whereHas('products', function($query) use ($product) {
270 270
                 return $query->where('id', $product->id);
271 271
             })
272
-            ->orWhereHas('categories', function ($query) use ($categoryIds) {
272
+            ->orWhereHas('categories', function($query) use ($categoryIds) {
273 273
                 return $query->whereIn('id', $categoryIds);
274 274
             })
275 275
             ->get();
276 276
 
277
-        $data = [];
277
+        $data = [ ];
278 278
         foreach ($discounts as $discount) {
279
-            $data[] = [
279
+            $data[ ] = [
280 280
                 'discount_id' => $discount->id,
281 281
                 'end_at' => $discount->end_at,
282 282
                 'price' => $discount->calculatePrice($product->base_price),
Please login to merge, or discard this patch.
controllers/Discounts.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,10 +39,10 @@
 block discarded – undo
39 39
     public function listExtendQuery($query)
40 40
     {
41 41
         $query->with([
42
-            'categories' => function ($category) {
42
+            'categories' => function($category) {
43 43
                 return $category->select('name');
44 44
             },
45
-            'products' => function ($product) {
45
+            'products' => function($product) {
46 46
                 return $product->select('name');
47 47
             },
48 48
         ])->selectStatus();
Please login to merge, or discard this patch.