@@ -34,7 +34,7 @@ discard block |
||
| 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 |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | 'products' => [ |
| 61 | 61 | 'Bedard\Shop\Models\Product', |
| 62 | 62 | 'table' => 'bedard_shop_category_product', |
| 63 | - 'pivot' => ['is_inherited'], |
|
| 63 | + 'pivot' => [ 'is_inherited' ], |
|
| 64 | 64 | ], |
| 65 | 65 | ]; |
| 66 | 66 | |
@@ -99,10 +99,10 @@ discard block |
||
| 99 | 99 | ->get(); |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - $children = []; |
|
| 102 | + $children = [ ]; |
|
| 103 | 103 | foreach ($categories as $category) { |
| 104 | 104 | if ($category->parent_id == $parent) { |
| 105 | - $children[] = $category->id; |
|
| 105 | + $children[ ] = $category->id; |
|
| 106 | 106 | $children = array_merge($children, self::getChildIds($category->id, $categories)); |
| 107 | 107 | } |
| 108 | 108 | } |
@@ -112,23 +112,23 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | public static function getParentIds($children, \October\Rain\Database\Collection $categories = null) |
| 114 | 114 | { |
| 115 | - if (! is_array($children)) { |
|
| 116 | - $children = [$children]; |
|
| 115 | + if (!is_array($children)) { |
|
| 116 | + $children = [ $children ]; |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | if ($categories === null) { |
| 120 | 120 | $categories = self::select('id', 'parent_id')->get(); |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - $parents = []; |
|
| 123 | + $parents = [ ]; |
|
| 124 | 124 | foreach ($children as $child) { |
| 125 | - $category = $categories->filter(function ($model) use ($child) { |
|
| 125 | + $category = $categories->filter(function($model) use ($child) { |
|
| 126 | 126 | return $model->id == $child; |
| 127 | 127 | })->first(); |
| 128 | 128 | |
| 129 | 129 | while ($category && $category->parent_id) { |
| 130 | - $parents[] = $category->parent_id; |
|
| 131 | - $category = $categories->filter(function ($model) use ($category) { |
|
| 130 | + $parents[ ] = $category->parent_id; |
|
| 131 | + $category = $categories->filter(function($model) use ($category) { |
|
| 132 | 132 | return $model->id == $category->parent_id; |
| 133 | 133 | })->first(); |
| 134 | 134 | } |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | */ |
| 209 | 209 | public function setNullParentId() |
| 210 | 210 | { |
| 211 | - if (! $this->parent_id) { |
|
| 211 | + if (!$this->parent_id) { |
|
| 212 | 212 | $this->parent_id = null; |
| 213 | 213 | } |
| 214 | 214 | } |
@@ -232,8 +232,8 @@ discard block |
||
| 232 | 232 | public static function updateMany(array $categories) |
| 233 | 233 | { |
| 234 | 234 | foreach ($categories as $category) { |
| 235 | - $id = $category['id']; |
|
| 236 | - unset($category['id']); |
|
| 235 | + $id = $category[ 'id' ]; |
|
| 236 | + unset($category[ 'id' ]); |
|
| 237 | 237 | self::whereId($id)->update($category); |
| 238 | 238 | } |
| 239 | 239 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 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 |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | foreach (Category::isParentOf($categoryIds)->lists('id') as $parentId) { |
| 91 | - $this->categories()->attach($parentId, ['is_inherited' => true]); |
|
| 91 | + $this->categories()->attach($parentId, [ 'is_inherited' => true ]); |
|
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | public static function syncAllInheritedCategories() |
| 149 | 149 | { |
| 150 | 150 | foreach (self::lists('id') as $id) { |
| 151 | - Queue::push(function ($job) use ($id) { |
|
| 151 | + Queue::push(function($job) use ($id) { |
|
| 152 | 152 | Product::findOrFail($id)->syncInheritedCategories(); |
| 153 | 153 | $job->delete(); |
| 154 | 154 | }); |
@@ -10,7 +10,7 @@ |
||
| 10 | 10 | |
| 11 | 11 | public function up() |
| 12 | 12 | { |
| 13 | - Schema::create('bedard_shop_products', function (Blueprint $table) { |
|
| 13 | + Schema::create('bedard_shop_products', function(Blueprint $table) { |
|
| 14 | 14 | $table->engine = 'InnoDB'; |
| 15 | 15 | $table->increments('id'); |
| 16 | 16 | $table->string('name')->default(''); |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | { |
| 9 | 9 | public function up() |
| 10 | 10 | { |
| 11 | - Schema::create('bedard_shop_categories', function (Blueprint $table) { |
|
| 11 | + Schema::create('bedard_shop_categories', function(Blueprint $table) { |
|
| 12 | 12 | $table->engine = 'InnoDB'; |
| 13 | 13 | $table->increments('id'); |
| 14 | 14 | $table->integer('parent_id')->unsigned()->nullable()->index(); |
@@ -8,12 +8,12 @@ |
||
| 8 | 8 | { |
| 9 | 9 | public function up() |
| 10 | 10 | { |
| 11 | - Schema::create('bedard_shop_category_product', function (Blueprint $table) { |
|
| 11 | + Schema::create('bedard_shop_category_product', function(Blueprint $table) { |
|
| 12 | 12 | $table->engine = 'InnoDB'; |
| 13 | 13 | $table->integer('category_id')->unsigned()->nullable(); |
| 14 | 14 | $table->integer('product_id')->unsigned()->nullable(); |
| 15 | 15 | $table->boolean('is_inherited')->default(false); |
| 16 | - $table->primary(['category_id', 'product_id']); |
|
| 16 | + $table->primary([ 'category_id', 'product_id' ]); |
|
| 17 | 17 | }); |
| 18 | 18 | } |
| 19 | 19 | |
@@ -20,19 +20,19 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | public function getLangJson($keys) |
| 22 | 22 | { |
| 23 | - $lang = []; |
|
| 23 | + $lang = [ ]; |
|
| 24 | 24 | |
| 25 | 25 | foreach ($keys as $key => $value) { |
| 26 | 26 | $isFiltered = gettype($value) === 'array'; |
| 27 | 27 | |
| 28 | - if (! $isFiltered) { |
|
| 28 | + if (!$isFiltered) { |
|
| 29 | 29 | $key = $value; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | $alias = explode('@', $key); |
| 33 | - $languageString = $alias[count($alias) - 1]; |
|
| 33 | + $languageString = $alias[ count($alias) - 1 ]; |
|
| 34 | 34 | |
| 35 | - $lang[$alias[0]] = $isFiltered |
|
| 35 | + $lang[ $alias[ 0 ] ] = $isFiltered |
|
| 36 | 36 | ? array_intersect_key(Lang::get($languageString), array_flip($value)) |
| 37 | 37 | : Lang::get($languageString); |
| 38 | 38 | } |
@@ -35,26 +35,26 @@ |
||
| 35 | 35 | 'icon' => 'icon-shopping-cart', |
| 36 | 36 | 'label' => 'bedard.shop::lang.plugin.navigation.shop', |
| 37 | 37 | 'order' => 500, |
| 38 | - 'permissions' => ['bedard.shop.*'], |
|
| 38 | + 'permissions' => [ 'bedard.shop.*' ], |
|
| 39 | 39 | 'url' => Backend::url('bedard/shop/products'), |
| 40 | 40 | 'sideMenu' => [ |
| 41 | 41 | 'products' => [ |
| 42 | 42 | 'label' => 'bedard.shop::lang.products.plural', |
| 43 | 43 | 'icon' => 'icon-cubes', |
| 44 | 44 | 'url' => Backend::url('bedard/shop/products'), |
| 45 | - 'permissions' => ['bedard.shop.products.*'], |
|
| 45 | + 'permissions' => [ 'bedard.shop.products.*' ], |
|
| 46 | 46 | ], |
| 47 | 47 | 'categories' => [ |
| 48 | 48 | 'label' => 'bedard.shop::lang.categories.plural', |
| 49 | 49 | 'icon' => 'icon-folder-o', |
| 50 | 50 | 'url' => Backend::url('bedard/shop/categories'), |
| 51 | - 'permissions' => ['bedard.shop.categories.*'], |
|
| 51 | + 'permissions' => [ 'bedard.shop.categories.*' ], |
|
| 52 | 52 | ], |
| 53 | 53 | 'discounts' => [ |
| 54 | 54 | 'label' => 'bedard.shop::lang.discounts.plural', |
| 55 | 55 | 'icon' => 'icon-clock-o', |
| 56 | 56 | 'url' => Backend::url('bedard/shop/discounts'), |
| 57 | - 'permissions' => ['bedard.shop.discounts.*'], |
|
| 57 | + 'permissions' => [ 'bedard.shop.discounts.*' ], |
|
| 58 | 58 | ], |
| 59 | 59 | ], |
| 60 | 60 | ], |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | { |
| 9 | 9 | public function up() |
| 10 | 10 | { |
| 11 | - Schema::create('bedard_shop_discounts', function (Blueprint $table) { |
|
| 11 | + Schema::create('bedard_shop_discounts', function(Blueprint $table) { |
|
| 12 | 12 | $table->engine = 'InnoDB'; |
| 13 | 13 | $table->increments('id'); |
| 14 | 14 | $table->string('name')->default(''); |
@@ -1,6 +1,5 @@ |
||
| 1 | 1 | <?php namespace Bedard\Shop\Traits; |
| 2 | 2 | |
| 3 | -use DB; |
|
| 4 | 3 | use October\Rain\Database\Builder; |
| 5 | 4 | |
| 6 | 5 | trait Subqueryable |