Test Failed
Push — master ( 9edbfe...d7c4b6 )
by Gianluca
09:59 queued 03:20
created
src/Http/Controllers/shop/ShopController.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -11,14 +11,14 @@
 block discarded – undo
11 11
 
12 12
 class ShopController extends Controller
13 13
 {
14
-    public function page($category_id=null){
14
+    public function page($category_id = null) {
15 15
         $products = Template::getProducts($category_id);
16 16
         $category = Category::find($category_id);
17 17
         $category_name = '';
18 18
         $category_description = '';
19
-        if($category){
19
+        if ($category) {
20 20
             $category_name = $category->name;
21 21
         };
22
-        return view('mongicommerce.pages.shop',compact('products','category_name','category_description'));
22
+        return view('mongicommerce.pages.shop', compact('products', 'category_name', 'category_description'));
23 23
     }
24 24
 }
Please login to merge, or discard this patch.
src/Http/Controllers/admin/AdminUpdatePackageController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
9 9
 
10 10
 class AdminUpdatePackageController extends Controller
11 11
 {
12
-    public function update(){
12
+    public function update() {
13 13
         #$dd = shell_exec('cd .. && composer update mongi/mongicommerce');
14 14
         $dd = shell_exec('cd .. && php artisan mongicommerce:update');
15 15
         echo '<pre>';
Please login to merge, or discard this patch.
src/Models/Product.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -11,18 +11,18 @@
 block discarded – undo
11 11
 {
12 12
     use HasFactory;
13 13
 
14
-    protected $dates = ["created_at","updated_at"];
14
+    protected $dates = ["created_at", "updated_at"];
15 15
 
16
-    public function items(){
16
+    public function items() {
17 17
         return $this->hasMany(ProductItem::class);
18 18
     }
19 19
 
20
-    public function category(){
20
+    public function category() {
21 21
         return $this->belongsTo(Category::class);
22 22
     }
23 23
 
24
-    public function details(){
25
-        return $this->hasManyThrough(ProductItemDetail::class,ProductItem::class);
24
+    public function details() {
25
+        return $this->hasManyThrough(ProductItemDetail::class, ProductItem::class);
26 26
     }
27 27
 
28 28
 
Please login to merge, or discard this patch.
src/Http/Controllers/admin/AdminNewProductVariationController.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,14 +15,14 @@  discard block
 block discarded – undo
15 15
 
16 16
 class AdminNewProductVariationController extends Controller
17 17
 {
18
-    public function page($id_product){
18
+    public function page($id_product) {
19 19
         $product = Product::find($id_product);
20 20
         $items = $product->items;
21 21
 
22
-        return view('mongicommerce::admin.pages.products.new_product_variation',['product' => $product,'items' => $items]);
22
+        return view('mongicommerce::admin.pages.products.new_product_variation', ['product' => $product, 'items' => $items]);
23 23
     }
24 24
 
25
-    public function createNewVariation(Request $r){
25
+    public function createNewVariation(Request $r) {
26 26
         $r->validate([
27 27
             'category_id' => 'required',
28 28
             'quantity' => 'required',
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
         ]);
33 33
         $product_id = $r->get('product_id');
34 34
 
35
-        $details = json_decode($r->get('details'),true);
36
-        $configuration_fields = json_decode($r->get('configuration_fields'),true);
35
+        $details = json_decode($r->get('details'), true);
36
+        $configuration_fields = json_decode($r->get('configuration_fields'), true);
37 37
         $quantity = $r->get('quantity');
38 38
         $price = $r->get('price');
39 39
         $product_name = $r->get('product_name');
@@ -51,12 +51,12 @@  discard block
 block discarded – undo
51 51
         $product_item->quantity = $quantity;
52 52
         $product_item->save();
53 53
 
54
-        $base64_str = substr($get_image, strpos($get_image, ",")+1);
54
+        $base64_str = substr($get_image, strpos($get_image, ",") + 1);
55 55
         $image = base64_decode($base64_str);
56 56
         $destinationPath = public_path().'/uploads/products_img/'.$product_item->product_id.'/'.$product_item->id.'/';
57 57
         $destinationPathDB = url('/').'/uploads/products_img/'.$product_item->product_id.'/'.$product_item->id.'/';
58 58
 
59
-        if(!File::isDirectory($destinationPath)){
59
+        if (!File::isDirectory($destinationPath)) {
60 60
             File::makeDirectory($destinationPath, $mode = 0777, true, true);
61 61
         }
62 62
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
         $product_item->image = $dbPath;
69 69
         $product_item->save();
70 70
 
71
-        foreach($details as $detail){
71
+        foreach ($details as $detail) {
72 72
             $detail_obj = (object) $detail;
73 73
             $product_detail = new ProductItemDetail();
74 74
             $product_detail->product_item_id = $product_item->id;
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
             $product_detail->save();
78 78
         }
79 79
 
80
-        foreach ($configuration_fields as $conf_field){
80
+        foreach ($configuration_fields as $conf_field) {
81 81
             $conf_fields_obj = (object) $conf_field;
82 82
             $configuration_field = new ProductConfigurationField();
83 83
             $configuration_field->product_item_id = $product_item->id;
Please login to merge, or discard this patch.
src/Http/Controllers/admin/AdminNewProductController.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -13,11 +13,11 @@  discard block
 block discarded – undo
13 13
 
14 14
 class AdminNewProductController extends Controller
15 15
 {
16
-    public function page(){
16
+    public function page() {
17 17
         return view('mongicommerce::admin.pages.products.new_product');
18 18
     }
19 19
 
20
-    public function createNewProduct(Request $r){
20
+    public function createNewProduct(Request $r) {
21 21
 
22 22
         $r->validate([
23 23
             'product_name' => 'required',
@@ -38,12 +38,12 @@  discard block
 block discarded – undo
38 38
         $product->category_id = $category_id;
39 39
         $product->save();
40 40
 
41
-        $base64_str = substr($get_image, strpos($get_image, ",")+1);
41
+        $base64_str = substr($get_image, strpos($get_image, ",") + 1);
42 42
         $image = base64_decode($base64_str);
43 43
         $destinationPath = public_path().'/uploads/products_img/'.$product->id.'/';
44 44
         $destinationPathDB = url('/').'/uploads/products_img/'.$product->id.'/';
45 45
 
46
-        if(!File::isDirectory($destinationPath)){
46
+        if (!File::isDirectory($destinationPath)) {
47 47
             File::makeDirectory($destinationPath, $mode = 0777, true, true);
48 48
         }
49 49
         $image_name = time().'.'.'jpeg';
Please login to merge, or discard this patch.
src/Libraries/Template.php 2 patches
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -16,11 +16,11 @@  discard block
 block discarded – undo
16 16
 
17 17
 class Template
18 18
 {
19
-    public static function getStructureCategories(){
19
+    public static function getStructureCategories() {
20 20
 
21 21
         $categories = Category::with('children')->whereNull('parent_id')->get();
22 22
         $tree = [];
23
-        foreach($categories as $category){
23
+        foreach ($categories as $category) {
24 24
             $tree[] = [
25 25
                 'id' => $category->id,
26 26
                 'text' => $category->name,
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
         return $tree;
32 32
     }
33 33
 
34
-    private static function recursiveChildren($childrens){
34
+    private static function recursiveChildren($childrens) {
35 35
         $childs = [];
36
-        foreach ($childrens as $children){
36
+        foreach ($childrens as $children) {
37 37
             $childs[] = [
38 38
                 'id' => $children->id,
39 39
                 'text' => $children->name,
@@ -49,34 +49,34 @@  discard block
 block discarded – undo
49 49
      * @param Int $id
50 50
      * @return Product
51 51
      */
52
-    public static function getProducts($id = null){
53
-        if($id === null){
52
+    public static function getProducts($id = null) {
53
+        if ($id === null) {
54 54
             $products = Product::all();
55
-        }else{
55
+        } else {
56 56
             $products = Category::find($id)->products;
57 57
         }
58 58
         return $products;
59 59
     }
60 60
 
61
-    public static function getDetailsFields(Product $product,$product_item_id){
61
+    public static function getDetailsFields(Product $product, $product_item_id) {
62 62
         $element = '<div class="row">';
63 63
 
64
-        foreach($product->details->groupBy('product_detail_id') as $key => $details){
64
+        foreach ($product->details->groupBy('product_detail_id') as $key => $details) {
65 65
 
66
-            $element.= self::generateDetailHtml(Detail::find($key),$details->groupBy('product_detail_value_id'),$product->id,$product_item_id);
66
+            $element .= self::generateDetailHtml(Detail::find($key), $details->groupBy('product_detail_value_id'), $product->id, $product_item_id);
67 67
         }
68
-        $element.= '<p class="show_error_product" style="color: red; display: none;">Prodotto non disponibile</p>';
68
+        $element .= '<p class="show_error_product" style="color: red; display: none;">Prodotto non disponibile</p>';
69 69
         $element .= '</div>';
70 70
         return $element;
71 71
     }
72 72
 
73
-    public static function generateHtmlField($type,$value,$label){
74
-        if($type !== 'textarea'){
73
+    public static function generateHtmlField($type, $value, $label) {
74
+        if ($type !== 'textarea') {
75 75
             $html = '';
76 76
             $html .= "<label>{$label}</label>";
77 77
             $html .= "<input class='form-control' type='{$type}' value='{$value}'>";
78 78
             return $html;
79
-        }else{
79
+        } else {
80 80
             $html = '';
81 81
             $html .= "<label>{$label}</label>";
82 82
             $html .= "<textarea class='form-control'>{$value}</textarea>";
@@ -84,40 +84,40 @@  discard block
 block discarded – undo
84 84
         }
85 85
     }
86 86
 
87
-    public static function getConfigurationFields($product_item_id){
88
-        $configurationFields = ProductConfigurationField::where('product_item_id',$product_item_id)->get();
87
+    public static function getConfigurationFields($product_item_id) {
88
+        $configurationFields = ProductConfigurationField::where('product_item_id', $product_item_id)->get();
89 89
         $element = '';
90
-        foreach ($configurationFields as $field){
90
+        foreach ($configurationFields as $field) {
91 91
                 $element .= '<div class="row">';
92
-                $element .= self::generateHtmlField($field->field->type,$field->value,$field->field->name);
92
+                $element .= self::generateHtmlField($field->field->type, $field->value, $field->field->name);
93 93
                 $element .= '</div>';
94 94
             }
95 95
         return $element;
96 96
     }
97 97
 
98
-    public static function buttonCart($product_item_id){
98
+    public static function buttonCart($product_item_id) {
99 99
         return "<button onclick='addToCart(this)' data-product_item_id='{$product_item_id}' class='btn btn-primary mt-3'>Salva nel carrello</button>";
100 100
     }
101 101
 
102
-    public static function generateDetailHtml($detail,$values,$product_id,$product_item_id){
102
+    public static function generateDetailHtml($detail, $values, $product_id, $product_item_id) {
103 103
 
104 104
         $type = $detail->type;
105 105
         $html = '';
106
-        if($type === 'select'){
106
+        if ($type === 'select') {
107 107
             $html = '<label>'.$detail->name.'</label>';
108
-            $html .= '<select onchange="getVariationProduct()" data-product_id="'.$product_id.'" data-detail_id="'.$detail->id .'" class="form-control mongifield_into_product">';
108
+            $html .= '<select onchange="getVariationProduct()" data-product_id="'.$product_id.'" data-detail_id="'.$detail->id.'" class="form-control mongifield_into_product">';
109 109
             $selected = '';
110 110
 
111
-            $details = ProductItemDetail::where('product_item_id',$product_item_id)->get();
111
+            $details = ProductItemDetail::where('product_item_id', $product_item_id)->get();
112 112
             $filter = [];
113
-            foreach ($details as $_detail){
113
+            foreach ($details as $_detail) {
114 114
                 $filter[$_detail->product_detail_id] = $_detail->product_detail_value_id;
115 115
             }
116
-            foreach ($values as $detail_value_id =>$value){
117
-                if(isset($filter[$detail->id])){
118
-                    if($filter[$detail->id] == $detail_value_id){
116
+            foreach ($values as $detail_value_id =>$value) {
117
+                if (isset($filter[$detail->id])) {
118
+                    if ($filter[$detail->id] == $detail_value_id) {
119 119
                         $selected = 'selected';
120
-                    }else{
120
+                    } else {
121 121
                         $selected = '';
122 122
                     }
123 123
                 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
     public static function getProducts($id = null){
53 53
         if($id === null){
54 54
             $products = Product::all();
55
-        }else{
55
+        } else{
56 56
             $products = Category::find($id)->products;
57 57
         }
58 58
         return $products;
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
             $html .= "<label>{$label}</label>";
77 77
             $html .= "<input class='form-control' type='{$type}' value='{$value}'>";
78 78
             return $html;
79
-        }else{
79
+        } else{
80 80
             $html = '';
81 81
             $html .= "<label>{$label}</label>";
82 82
             $html .= "<textarea class='form-control'>{$value}</textarea>";
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
                 if(isset($filter[$detail->id])){
118 118
                     if($filter[$detail->id] == $detail_value_id){
119 119
                         $selected = 'selected';
120
-                    }else{
120
+                    } else{
121 121
                         $selected = '';
122 122
                     }
123 123
                 }
Please login to merge, or discard this patch.
src/Http/Controllers/shop/ShopSingleProductController.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -13,16 +13,16 @@
 block discarded – undo
13 13
 
14 14
 class ShopSingleProductController extends Controller
15 15
 {
16
-     public function page($id,$product_item_id = null){
16
+     public function page($id, $product_item_id = null) {
17 17
          $product = Product::find($id);
18
-         if($product_item_id == null){
19
-             return redirect()->route('shop.single.product',[$product->id,$product->items->first()->id]);
18
+         if ($product_item_id == null) {
19
+             return redirect()->route('shop.single.product', [$product->id, $product->items->first()->id]);
20 20
          }
21
-         $details_fields = Template::getDetailsFields($product,$product_item_id);
21
+         $details_fields = Template::getDetailsFields($product, $product_item_id);
22 22
          $configuration_fields = Template::getConfigurationFields($product_item_id);
23 23
          $btn_cart = Template::buttonCart($product_item_id);
24 24
 
25 25
 
26
-         return view('mongicommerce.pages.single-product',compact('product','details_fields','configuration_fields','btn_cart'));
26
+         return view('mongicommerce.pages.single-product', compact('product', 'details_fields', 'configuration_fields', 'btn_cart'));
27 27
      }
28 28
 }
Please login to merge, or discard this patch.
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -7,14 +7,14 @@
 block discarded – undo
7 7
 
8 8
 class ShopSingleProductController extends Controller
9 9
 {
10
-     public function page($id,$product_item_id = null){
11
-         $product = Product::find($id);
12
-         if($product_item_id == null){
13
-             return redirect()->route('shop.single.product',[$product->id,$product->items->first()->id]);
14
-         }
15
-         $details_fields = Template::getDetailsFields($product,$product_item_id);
16
-         $configuration_fields = Template::getConfigurationFields($product_item_id);
17
-         $btn_cart = Template::buttonCart($product_item_id);
18
-         return view('mongicommerce.pages.single-product',compact('product','details_fields','configuration_fields','btn_cart'));
19
-     }
10
+        public function page($id,$product_item_id = null){
11
+            $product = Product::find($id);
12
+            if($product_item_id == null){
13
+                return redirect()->route('shop.single.product',[$product->id,$product->items->first()->id]);
14
+            }
15
+            $details_fields = Template::getDetailsFields($product,$product_item_id);
16
+            $configuration_fields = Template::getConfigurationFields($product_item_id);
17
+            $btn_cart = Template::buttonCart($product_item_id);
18
+            return view('mongicommerce.pages.single-product',compact('product','details_fields','configuration_fields','btn_cart'));
19
+        }
20 20
 }
Please login to merge, or discard this patch.
src/Http/Controllers/admin/AdminNewSingleProductController.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -14,12 +14,12 @@  discard block
 block discarded – undo
14 14
 
15 15
 class AdminNewSingleProductController extends Controller
16 16
 {
17
-    public function page(){
17
+    public function page() {
18 18
         $caregories = Category::all();
19
-        return view('mongicommerce::admin.pages.products.new_single_product',['categories' => $caregories]);
19
+        return view('mongicommerce::admin.pages.products.new_single_product', ['categories' => $caregories]);
20 20
     }
21 21
 
22
-    public function createNewSingleProduct(Request $r){
22
+    public function createNewSingleProduct(Request $r) {
23 23
         $r->validate([
24 24
             'category_id' => 'required',
25 25
             'quantity' => 'required',
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
             'image' => 'required',
28 28
         ]);
29 29
 
30
-        $configuration_fields = json_decode($r->get('configuration_fields'),true);
30
+        $configuration_fields = json_decode($r->get('configuration_fields'), true);
31 31
         $quantity = $r->get('quantity');
32 32
         $price = $r->get('price');
33 33
         $product_name = $r->get('product_name');
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
         $product->image = null;
44 44
         $product->save();
45 45
 
46
-        $base64_str = substr($get_image, strpos($get_image, ",")+1);
46
+        $base64_str = substr($get_image, strpos($get_image, ",") + 1);
47 47
         $image = base64_decode($base64_str);
48 48
         $destinationPath = public_path().'/uploads/products_img/'.$product->id.'/'.$product->id.'/';
49 49
         $destinationPathDB = url('/').'/uploads/products_img/'.$product->id.'/'.$product->id.'/';
50 50
 
51
-        if(!File::isDirectory($destinationPath)){
51
+        if (!File::isDirectory($destinationPath)) {
52 52
             File::makeDirectory($destinationPath, $mode = 0777, true, true);
53 53
         }
54 54
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
         $product_item->quantity = $quantity;
71 71
         $product_item->save();
72 72
 
73
-        foreach ($configuration_fields as $conf_field){
73
+        foreach ($configuration_fields as $conf_field) {
74 74
             $conf_fields_obj = (object) $conf_field;
75 75
             $configuration_field = new ProductConfigurationField();
76 76
             $configuration_field->product_item_id = $product_item->id;
Please login to merge, or discard this patch.
src/Models/ProductConfigurationField.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,8 +11,8 @@
 block discarded – undo
11 11
 {
12 12
     use HasFactory;
13 13
 
14
-    public function field(){
15
-        return $this->belongsTo(ConfigurationField::class,'config_field_id');
14
+    public function field() {
15
+        return $this->belongsTo(ConfigurationField::class, 'config_field_id');
16 16
     }
17 17
 
18 18
 }
Please login to merge, or discard this patch.