Completed
Push — master ( d52f5c...f665bb )
by Scott
02:35
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   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
     /**
35 35
      * @var array Guarded fields
36 36
      */
37
-    protected $guarded = ['*'];
37
+    protected $guarded = [ '*' ];
38 38
 
39 39
     /**
40 40
      * @var array Fillable fields
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     public function filterFields($fields)
148 148
     {
149 149
         $fields->amount_exact->hidden = $this->is_percentage;
150
-        $fields->amount_percentage->hidden = ! $this->is_percentage;
150
+        $fields->amount_percentage->hidden = !$this->is_percentage;
151 151
     }
152 152
 
153 153
     /**
@@ -159,9 +159,9 @@  discard block
 block discarded – undo
159 159
     {
160 160
         $categoryProductIds = $this->categories()
161 161
             ->select('id')
162
-            ->with(['products' => function ($products) {
162
+            ->with([ 'products' => function($products) {
163 163
                 return $products->select('id');
164
-            }])
164
+            } ])
165 165
             ->lists('categories.products.id');
166 166
 
167 167
         $productIds = $this->products()->lists('id');
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
     public function savePrices()
178 178
     {
179 179
         $id = $this->id;
180
-        Queue::push(function ($job) use ($id) {
180
+        Queue::push(function($job) use ($id) {
181 181
             $discount = Discount::findOrFail($id);
182 182
             $productIds = $discount->getAllProductIds();
183 183
             $products = Product::whereIn('id', $productIds)->select('id', 'base_price')->get();
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
      */
208 208
     public static function syncAllPrices()
209 209
     {
210
-        $data = [];
210
+        $data = [ ];
211 211
         $discounts = self::isNotExpired()->with('categories.products', 'products')->get();
212 212
         foreach ($discounts as $discount) {
213 213
             $products = $discount->products;
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
             }
217 217
 
218 218
             foreach ($products as $product) {
219
-                $data[] = [
219
+                $data[ ] = [
220 220
                     'discount_id' => $discount->id,
221 221
                     'end_at' => $discount->end_at,
222 222
                     'price' => $discount->calculatePrice($product->base_price),
@@ -238,9 +238,9 @@  discard block
 block discarded – undo
238 238
             })
239 239
             ->get();
240 240
 
241
-        $data = [];
241
+        $data = [ ];
242 242
         foreach ($discounts as $discount) {
243
-            $data[] = [
243
+            $data[ ] = [
244 244
                 'discount_id' => $discount->id,
245 245
                 'end_at' => $discount->end_at,
246 246
                 'price' => $discount->calculatePrice($product->base_price),
Please login to merge, or discard this patch.