@@ -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 | } |
@@ -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 | } |
@@ -26,6 +26,9 @@ |
||
| 26 | 26 | $child2 = Factory::create(new Category, ['name' => 'Child 2', 'slug' => 'child-2', 'parent_id' => $parent2->id]); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | + /** |
|
| 30 | + * @param integer $count |
|
| 31 | + */ |
|
| 29 | 32 | protected function seedProducts($count) |
| 30 | 33 | { |
| 31 | 34 | $categories = Category::count(); |
@@ -20,10 +20,10 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | protected function seedCategories() |
| 22 | 22 | { |
| 23 | - $parent1 = Factory::create(new Category, ['name' => 'Parent 1', 'slug' => 'parent-1']); |
|
| 24 | - $parent2 = Factory::create(new Category, ['name' => 'Parent 2', 'slug' => 'parent-2']); |
|
| 25 | - Factory::create(new Category, ['name' => 'Child 1', 'slug' => 'child-1', 'parent_id' => $parent1->id]); |
|
| 26 | - Factory::create(new Category, ['name' => 'Child 2', 'slug' => 'child-2', 'parent_id' => $parent2->id]); |
|
| 23 | + $parent1 = Factory::create(new Category, [ 'name' => 'Parent 1', 'slug' => 'parent-1' ]); |
|
| 24 | + $parent2 = Factory::create(new Category, [ 'name' => 'Parent 2', 'slug' => 'parent-2' ]); |
|
| 25 | + Factory::create(new Category, [ 'name' => 'Child 1', 'slug' => 'child-1', 'parent_id' => $parent1->id ]); |
|
| 26 | + Factory::create(new Category, [ 'name' => 'Child 2', 'slug' => 'child-2', 'parent_id' => $parent2->id ]); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | protected function seedProducts($count) |
@@ -31,8 +31,8 @@ discard block |
||
| 31 | 31 | $categories = Category::count(); |
| 32 | 32 | |
| 33 | 33 | for ($i = 0; $i < $count; $i++) { |
| 34 | - $product = Factory::create(new Product, ['name' => 'Product '.$i, 'slug' => 'product-'.$i]); |
|
| 35 | - $product->categories()->sync([rand(1, $categories)]); |
|
| 34 | + $product = Factory::create(new Product, [ 'name' => 'Product '.$i, 'slug' => 'product-'.$i ]); |
|
| 35 | + $product->categories()->sync([ rand(1, $categories) ]); |
|
| 36 | 36 | } |
| 37 | 37 | } |
| 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(''); |
@@ -8,11 +8,11 @@ |
||
| 8 | 8 | { |
| 9 | 9 | public function up() |
| 10 | 10 | { |
| 11 | - Schema::create('bedard_shop_category_discount', function (Blueprint $table) { |
|
| 11 | + Schema::create('bedard_shop_category_discount', function(Blueprint $table) { |
|
| 12 | 12 | $table->engine = 'InnoDB'; |
| 13 | 13 | $table->integer('category_id')->unsigned()->nullable(); |
| 14 | 14 | $table->integer('discount_id')->unsigned()->nullable(); |
| 15 | - $table->primary(['category_id', 'discount_id']); |
|
| 15 | + $table->primary([ 'category_id', 'discount_id' ]); |
|
| 16 | 16 | }); |
| 17 | 17 | } |
| 18 | 18 | |