@@ -10,11 +10,11 @@ discard block |
||
10 | 10 | |
11 | 11 | class Template |
12 | 12 | { |
13 | - public static function getStructureCategories(){ |
|
13 | + public static function getStructureCategories() { |
|
14 | 14 | |
15 | 15 | $categories = Category::with('children')->whereNull('parent_id')->get(); |
16 | 16 | $tree = []; |
17 | - foreach($categories as $category){ |
|
17 | + foreach ($categories as $category) { |
|
18 | 18 | $tree[] = [ |
19 | 19 | 'id' => $category->id, |
20 | 20 | 'text' => $category->name, |
@@ -25,9 +25,9 @@ discard block |
||
25 | 25 | return $tree; |
26 | 26 | } |
27 | 27 | |
28 | - private static function recursiveChildren($childrens){ |
|
28 | + private static function recursiveChildren($childrens) { |
|
29 | 29 | $childs = []; |
30 | - foreach ($childrens as $children){ |
|
30 | + foreach ($childrens as $children) { |
|
31 | 31 | $childs[] = [ |
32 | 32 | 'id' => $children->id, |
33 | 33 | 'text' => $children->name, |
@@ -43,15 +43,15 @@ discard block |
||
43 | 43 | * @param Int $id |
44 | 44 | * @return Product |
45 | 45 | */ |
46 | - public static function getProducts($id = null){ |
|
47 | - if($id === null){ |
|
46 | + public static function getProducts($id = null) { |
|
47 | + if ($id === null) { |
|
48 | 48 | $products = Product::all(); |
49 | - }else{ |
|
50 | - if(Category::find($id)){ |
|
49 | + } else { |
|
50 | + if (Category::find($id)) { |
|
51 | 51 | $belong_to_this_category = Category::find($id)->children->pluck('id')->toArray(); |
52 | 52 | $result = array_merge($belong_to_this_category, [0 =>$id]); |
53 | - $products = Product::whereIn('category_id',$result)->get(); |
|
54 | - }else{ |
|
53 | + $products = Product::whereIn('category_id', $result)->get(); |
|
54 | + } else { |
|
55 | 55 | $products = []; |
56 | 56 | } |
57 | 57 | } |
@@ -46,12 +46,12 @@ |
||
46 | 46 | public static function getProducts($id = null){ |
47 | 47 | if($id === null){ |
48 | 48 | $products = Product::all(); |
49 | - }else{ |
|
49 | + } else{ |
|
50 | 50 | if(Category::find($id)){ |
51 | 51 | $belong_to_this_category = Category::find($id)->children->pluck('id')->toArray(); |
52 | 52 | $result = array_merge($belong_to_this_category, [0 =>$id]); |
53 | 53 | $products = Product::whereIn('category_id',$result)->get(); |
54 | - }else{ |
|
54 | + } else{ |
|
55 | 55 | $products = []; |
56 | 56 | } |
57 | 57 | } |