Test Failed
Push — master ( 1f85df...a52154 )
by Gianluca
05:34
created
src/Libraries/Template.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
 
16 16
 class Template
17 17
 {
18
-    public static function getStructureCategories(){
18
+    public static function getStructureCategories() {
19 19
 
20 20
         $categories = Category::with('children')->whereNull('parent_id')->get();
21 21
         $tree = [];
22
-        foreach($categories as $category){
22
+        foreach ($categories as $category) {
23 23
             $tree[] = [
24 24
                 'id' => $category->id,
25 25
                 'text' => $category->name,
@@ -30,9 +30,9 @@  discard block
 block discarded – undo
30 30
         return $tree;
31 31
     }
32 32
 
33
-    private static function recursiveChildren($childrens){
33
+    private static function recursiveChildren($childrens) {
34 34
         $childs = [];
35
-        foreach ($childrens as $children){
35
+        foreach ($childrens as $children) {
36 36
             $childs[] = [
37 37
                 'id' => $children->id,
38 38
                 'text' => $children->name,
@@ -48,34 +48,34 @@  discard block
 block discarded – undo
48 48
      * @param Int $id
49 49
      * @return Product
50 50
      */
51
-    public static function getProducts($id = null){
52
-        if($id === null){
51
+    public static function getProducts($id = null) {
52
+        if ($id === null) {
53 53
             $products = Product::all();
54
-        }else{
54
+        } else {
55 55
             $products = Category::find($id)->products;
56 56
         }
57 57
         return $products;
58 58
     }
59 59
 
60
-    public static function getDetailsFields(Product $product,$product_item_id){
60
+    public static function getDetailsFields(Product $product, $product_item_id) {
61 61
         $element = '<div class="row col">';
62 62
 
63
-        foreach($product->details->groupBy('product_detail_id') as $key => $details){
63
+        foreach ($product->details->groupBy('product_detail_id') as $key => $details) {
64 64
 
65
-            $element.= self::generateDetailHtml(Detail::find($key),$details->groupBy('product_detail_value_id'),$product->id,$product_item_id);
65
+            $element .= self::generateDetailHtml(Detail::find($key), $details->groupBy('product_detail_value_id'), $product->id, $product_item_id);
66 66
         }
67
-        $element.= '<p class="show_error_product" style="color: red; display: none;">Prodotto non disponibile</p>';
67
+        $element .= '<p class="show_error_product" style="color: red; display: none;">Prodotto non disponibile</p>';
68 68
         $element .= '</div>';
69 69
         return $element;
70 70
     }
71 71
 
72
-    public static function generateHtmlField($type,$value,$label){
73
-        if($type !== 'textarea'){
72
+    public static function generateHtmlField($type, $value, $label) {
73
+        if ($type !== 'textarea') {
74 74
             $html = '';
75 75
             $html .= "<label>{$label}</label>";
76 76
             $html .= "<input class='form-control' type='{$type}' value='{$value}'>";
77 77
             return $html;
78
-        }else{
78
+        } else {
79 79
             $html = '';
80 80
             $html .= "<label>{$label}</label>";
81 81
             $html .= "<textarea class='form-control'>{$value}</textarea>";
@@ -83,40 +83,40 @@  discard block
 block discarded – undo
83 83
         }
84 84
     }
85 85
 
86
-    public static function getConfigurationFields($product_item_id){
87
-        $configurationFields = ProductConfigurationField::where('product_item_id',$product_item_id)->get();
86
+    public static function getConfigurationFields($product_item_id) {
87
+        $configurationFields = ProductConfigurationField::where('product_item_id', $product_item_id)->get();
88 88
         $element = '<div class="col row">';
89
-        foreach ($configurationFields as $field){
90
-                $element .= self::generateHtmlField($field->field->type,$field->value,$field->field->name);
89
+        foreach ($configurationFields as $field) {
90
+                $element .= self::generateHtmlField($field->field->type, $field->value, $field->field->name);
91 91
 
92 92
             }
93 93
             $element .= '</div>';
94 94
         return $element;
95 95
     }
96 96
 
97
-    public static function buttonCart($product_item_id){
97
+    public static function buttonCart($product_item_id) {
98 98
         return "<button onclick='addToCart(this)' data-product_item_id='{$product_item_id}' class='btn btn-primary mt-3'>Salva nel carrello</button>";
99 99
     }
100 100
 
101
-    public static function generateDetailHtml($detail,$values,$product_id,$product_item_id){
101
+    public static function generateDetailHtml($detail, $values, $product_id, $product_item_id) {
102 102
 
103 103
         $type = $detail->type;
104 104
         $html = '';
105
-        if($type === 'select'){
105
+        if ($type === 'select') {
106 106
             $html = '<label>'.$detail->name.'</label>';
107
-            $html .= '<select onchange="getVariationProduct()" data-product_id="'.$product_id.'" data-detail_id="'.$detail->id .'" class="form-control mongifield_into_product">';
107
+            $html .= '<select onchange="getVariationProduct()" data-product_id="'.$product_id.'" data-detail_id="'.$detail->id.'" class="form-control mongifield_into_product">';
108 108
             $selected = '';
109 109
 
110
-            $details = ProductItemDetail::where('product_item_id',$product_item_id)->get();
110
+            $details = ProductItemDetail::where('product_item_id', $product_item_id)->get();
111 111
             $filter = [];
112
-            foreach ($details as $_detail){
112
+            foreach ($details as $_detail) {
113 113
                 $filter[$_detail->product_detail_id] = $_detail->product_detail_value_id;
114 114
             }
115
-            foreach ($values as $detail_value_id =>$value){
116
-                if(isset($filter[$detail->id])){
117
-                    if($filter[$detail->id] == $detail_value_id){
115
+            foreach ($values as $detail_value_id =>$value) {
116
+                if (isset($filter[$detail->id])) {
117
+                    if ($filter[$detail->id] == $detail_value_id) {
118 118
                         $selected = 'selected';
119
-                    }else{
119
+                    } else {
120 120
                         $selected = '';
121 121
                     }
122 122
                 }
@@ -129,12 +129,12 @@  discard block
 block discarded – undo
129 129
         return $html;
130 130
     }
131 131
 
132
-    public static function MoveSessionToCart($user_id){
132
+    public static function MoveSessionToCart($user_id) {
133 133
         $user = User::find($user_id);
134 134
         $elements_in_cart = session('cart');
135
-        if(!empty($elements_in_cart)){
136
-            if(Cart::where('user_id',$user->id)->count() <= 0){
137
-                foreach($elements_in_cart as $product_id => $count){
135
+        if (!empty($elements_in_cart)) {
136
+            if (Cart::where('user_id', $user->id)->count() <= 0) {
137
+                foreach ($elements_in_cart as $product_id => $count) {
138 138
                     $cart = new Cart();
139 139
                     $cart->user_id = $user->id;
140 140
                     $cart->product_item_id = $product_id;
Please login to merge, or discard this patch.