Completed
Push — master ( 054210...4c2c87 )
by Scott
03:56
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.
models/Product.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
     /**
28 28
      * @var array Guarded fields
29 29
      */
30
-    protected $guarded = ['*'];
30
+    protected $guarded = [ '*' ];
31 31
 
32 32
     /**
33 33
      * @var array Fillable fields
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
         }
101 101
 
102 102
         foreach (Category::isParentOf($categoryIds)->lists('id') as $parentId) {
103
-            $this->categories()->attach($parentId, ['is_inherited' => true]);
103
+            $this->categories()->attach($parentId, [ 'is_inherited' => true ]);
104 104
         }
105 105
     }
106 106
 
@@ -145,8 +145,8 @@  discard block
 block discarded – undo
145 145
     public function saveBasePrice()
146 146
     {
147 147
         Price::updateOrCreate(
148
-            ['product_id' => $this->id, 'discount_id' => null],
149
-            ['price' => $this->base_price]
148
+            [ 'product_id' => $this->id, 'discount_id' => null ],
149
+            [ 'price' => $this->base_price ]
150 150
         );
151 151
     }
152 152
 
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
     public static function syncAllInheritedCategories()
174 174
     {
175 175
         foreach (self::lists('id') as $id) {
176
-            Queue::push(function ($job) use ($id) {
176
+            Queue::push(function($job) use ($id) {
177 177
                 Product::findOrFail($id)->syncInheritedCategories();
178 178
                 $job->delete();
179 179
             });
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/Discount.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
     /**
34 34
      * @var array Guarded fields
35 35
      */
36
-    protected $guarded = ['*'];
36
+    protected $guarded = [ '*' ];
37 37
 
38 38
     /**
39 39
      * @var array Fillable fields
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
     public function filterFields($fields)
147 147
     {
148 148
         $fields->amount_exact->hidden = $this->is_percentage;
149
-        $fields->amount_percentage->hidden = ! $this->is_percentage;
149
+        $fields->amount_percentage->hidden = !$this->is_percentage;
150 150
     }
151 151
 
152 152
     /**
@@ -158,9 +158,9 @@  discard block
 block discarded – undo
158 158
     {
159 159
         $categoryProductIds = $this->categories()
160 160
             ->select('id')
161
-            ->with(['products' => function ($products) {
161
+            ->with([ 'products' => function($products) {
162 162
                 return $products->select('id');
163
-            }])
163
+            } ])
164 164
             ->lists('categories.products.id');
165 165
 
166 166
         $productIds = $this->products()->lists('id');
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
         $id = $this->id;
179 179
         $productIds = $this->getAllProductIds();
180 180
 
181
-        Queue::push(function ($job) use ($id, $productIds) {
181
+        Queue::push(function($job) use ($id, $productIds) {
182 182
             $discount = Discount::findOrFail($id);
183 183
             $products = Product::whereIn('id', $productIds)->select('id', 'base_price')->get();
184 184
 
Please login to merge, or discard this patch.
models/Category.php 1 patch
Spacing   +17 added lines, -17 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
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
         'products' => [
65 65
             'Bedard\Shop\Models\Product',
66 66
             'table' => 'bedard_shop_category_product',
67
-            'pivot' => ['is_inherited'],
67
+            'pivot' => [ 'is_inherited' ],
68 68
         ],
69 69
     ];
70 70
 
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
     public static function getParentCategoryIds() {
106 106
         $categories = self::select('id', 'parent_id')->get();
107 107
 
108
-        $tree = [];
108
+        $tree = [ ];
109 109
         foreach ($categories as $category) {
110
-            $tree[$category->id] = self::walkParentCategories($categories, $category);
110
+            $tree[ $category->id ] = self::walkParentCategories($categories, $category);
111 111
         }
112 112
 
113 113
         return $tree;
@@ -129,10 +129,10 @@  discard block
 block discarded – undo
129 129
                 ->get();
130 130
         }
131 131
 
132
-        $children = [];
132
+        $children = [ ];
133 133
         foreach ($categories as $category) {
134 134
             if ($category->parent_id == $parent) {
135
-                $children[] = $category->id;
135
+                $children[ ] = $category->id;
136 136
                 $children = array_merge($children, self::getChildIds($category->id, $categories));
137 137
             }
138 138
         }
@@ -142,23 +142,23 @@  discard block
 block discarded – undo
142 142
 
143 143
     public static function getParentIds($children, \October\Rain\Database\Collection $categories = null)
144 144
     {
145
-        if (! is_array($children)) {
146
-            $children = [$children];
145
+        if (!is_array($children)) {
146
+            $children = [ $children ];
147 147
         }
148 148
 
149 149
         if ($categories === null) {
150 150
             $categories = self::select('id', 'parent_id')->get();
151 151
         }
152 152
 
153
-        $parents = [];
153
+        $parents = [ ];
154 154
         foreach ($children as $child) {
155
-            $category = $categories->filter(function ($model) use ($child) {
155
+            $category = $categories->filter(function($model) use ($child) {
156 156
                 return $model->id == $child;
157 157
             })->first();
158 158
 
159 159
             while ($category && $category->parent_id) {
160
-                $parents[] = $category->parent_id;
161
-                $category = $categories->filter(function ($model) use ($category) {
160
+                $parents[ ] = $category->parent_id;
161
+                $category = $categories->filter(function($model) use ($category) {
162 162
                     return $model->id == $category->parent_id;
163 163
                 })->first();
164 164
             }
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
      */
239 239
     public function setNullParentId()
240 240
     {
241
-        if (! $this->parent_id) {
241
+        if (!$this->parent_id) {
242 242
             $this->parent_id = null;
243 243
         }
244 244
     }
@@ -274,8 +274,8 @@  discard block
 block discarded – undo
274 274
     public static function updateMany(array $categories)
275 275
     {
276 276
         foreach ($categories as $category) {
277
-            $id = $category['id'];
278
-            unset($category['id']);
277
+            $id = $category[ 'id' ];
278
+            unset($category[ 'id' ]);
279 279
             self::whereId($id)->update($category);
280 280
         }
281 281
     }
@@ -288,10 +288,10 @@  discard block
 block discarded – undo
288 288
      * @param  array                                $tree           Tree of parent IDs
289 289
      * @return arrau
290 290
      */
291
-    public static function walkParentCategories($categories, $category, $tree = [])
291
+    public static function walkParentCategories($categories, $category, $tree = [ ])
292 292
     {
293 293
         if ($category->parent_id !== null) {
294
-            $tree[] = $category->parent_id;
294
+            $tree[ ] = $category->parent_id;
295 295
             $tree = array_merge($tree, self::walkParentCategories($categories, $categories->find($category->parent_id)));
296 296
         }
297 297
 
Please login to merge, or discard this patch.