@@ -65,7 +65,6 @@ |
||
| 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) |
@@ -35,7 +35,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | |
@@ -33,7 +33,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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'); |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | public function savePrices() |
| 177 | 177 | { |
| 178 | 178 | $id = $this->id; |
| 179 | - Queue::push(function ($job) use ($id) { |
|
| 179 | + Queue::push(function($job) use ($id) { |
|
| 180 | 180 | $discount = Discount::findOrFail($id); |
| 181 | 181 | $productIds = $discount->getAllProductIds(); |
| 182 | 182 | $products = Product::whereIn('id', $productIds)->select('id', 'base_price')->get(); |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | */ |
| 207 | 207 | public static function syncAllPrices() |
| 208 | 208 | { |
| 209 | - $data = []; |
|
| 209 | + $data = [ ]; |
|
| 210 | 210 | $discounts = self::isNotExpired()->with('categories.products', 'products')->get(); |
| 211 | 211 | foreach ($discounts as $discount) { |
| 212 | 212 | $products = $discount->products; |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | foreach ($products as $product) { |
| 218 | - $data[] = [ |
|
| 218 | + $data[ ] = [ |
|
| 219 | 219 | 'discount_id' => $discount->id, |
| 220 | 220 | 'end_at' => $discount->end_at, |
| 221 | 221 | 'price' => $discount->calculatePrice($product->base_price), |