Test Failed
Push — master ( befccc...a4b299 )
by Gianluca
19:49
created
src/Models/Category.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,11 +29,11 @@
 block discarded – undo
29 29
         return $this->children_rec()->with('children');
30 30
     }
31 31
 
32
-    public function configuration_fields(){
32
+    public function configuration_fields() {
33 33
         return $this->hasMany(ConfigurationField::class);
34 34
     }
35 35
 
36
-    public function products(){
36
+    public function products() {
37 37
         return $this->hasMany(Product::class);
38 38
     }
39 39
 
Please login to merge, or discard this patch.
src/Http/Controllers/shop/ShopShowVariationProductController.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -24,14 +24,14 @@  discard block
 block discarded – undo
24 24
 
25 25
         $g = '';
26 26
         foreach ($informations as $key => $information) {
27
-            $information = (object)$information;
27
+            $information = (object) $information;
28 28
             $product_detail_id = $information->product_detail_id;
29 29
             $product_detail_value_id = $information->product_detail_value_id;
30 30
             $condition = '';
31 31
 
32
-            if(count($informations) == $key +1){
32
+            if (count($informations) == $key + 1) {
33 33
                 $condition = '';
34
-            }else{
34
+            } else {
35 35
                 $condition = 'or';
36 36
             }
37 37
             $g .= ('(a.product_detail_id ='.$product_detail_id.' and a.product_detail_value_id ='.$product_detail_value_id.') '.$condition.'');
@@ -40,16 +40,16 @@  discard block
 block discarded – undo
40 40
 
41 41
         $result = $q->first();
42 42
 
43
-        if($result){
43
+        if ($result) {
44 44
             $filters = $result->num_details >= count($informations);
45
-            if($filters){
45
+            if ($filters) {
46 46
                 $product_item_id = $result->product_item_id;
47 47
 
48
-                return response()->json(route('shop.single.product',[$product_id,$product_item_id]));
49
-            }else{
48
+                return response()->json(route('shop.single.product', [$product_id, $product_item_id]));
49
+            } else {
50 50
                 return response()->json(false);
51 51
             }
52
-        }else{
52
+        } else {
53 53
             return response()->json(false);
54 54
         }
55 55
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 
32 32
             if(count($informations) == $key +1){
33 33
                 $condition = '';
34
-            }else{
34
+            } else{
35 35
                 $condition = 'or';
36 36
             }
37 37
             $g .= ('(a.product_detail_id ='.$product_detail_id.' and a.product_detail_value_id ='.$product_detail_value_id.') '.$condition.'');
@@ -46,10 +46,10 @@  discard block
 block discarded – undo
46 46
                 $product_item_id = $result->product_item_id;
47 47
 
48 48
                 return response()->json(route('shop.single.product',[$product_id,$product_item_id]));
49
-            }else{
49
+            } else{
50 50
                 return response()->json(false);
51 51
             }
52
-        }else{
52
+        } else{
53 53
             return response()->json(false);
54 54
         }
55 55
 
Please login to merge, or discard this patch.
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/routes.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -14,56 +14,56 @@
 block discarded – undo
14 14
 use Mongi\Mongicommerce\Http\Controllers\shop\ShopShowVariationProductController;
15 15
 use Mongi\Mongicommerce\Http\Controllers\shop\ShopSingleProductController;
16 16
 
17
-Route::group(['middleware' => ['web']], function () {
17
+Route::group(['middleware' => ['web']], function() {
18 18
     /*****************
19 19
      *-----SHOP------*
20 20
      *****************/
21 21
 
22
-    Route::get('/shop/{id?}',[ShopController::class,'page'])->name('shop');
23
-    Route::get('/prodotto/{id}/{item_id?}',[ShopSingleProductController::class,'page'])->name('shop.single.product');
22
+    Route::get('/shop/{id?}', [ShopController::class, 'page'])->name('shop');
23
+    Route::get('/prodotto/{id}/{item_id?}', [ShopSingleProductController::class, 'page'])->name('shop.single.product');
24 24
 
25
-    Route::post('/shop/get/product-information',[ShopShowVariationProductController::class,'getData'])->name('shop.get.product.information');
25
+    Route::post('/shop/get/product-information', [ShopShowVariationProductController::class, 'getData'])->name('shop.get.product.information');
26 26
 
27 27
 
28 28
     /*****************
29 29
      *------GET------*
30 30
      *****************/
31
-    Route::get('/admin/dashboard',[DashboardController::class,'page'])->name('admin.dashboard');
32
-    Route::get('/admin/categorie/',[AdminCategoryController::class,'page'])->name('admin.category.new');
33
-    Route::get('/admin/dettagli',[AdminDetailController::class,'page'])->name('admin.details');
34
-    Route::get('/admin/settings',[AdminSettingsController::class,'page'])->name('admin.settings');
31
+    Route::get('/admin/dashboard', [DashboardController::class, 'page'])->name('admin.dashboard');
32
+    Route::get('/admin/categorie/', [AdminCategoryController::class, 'page'])->name('admin.category.new');
33
+    Route::get('/admin/dettagli', [AdminDetailController::class, 'page'])->name('admin.details');
34
+    Route::get('/admin/settings', [AdminSettingsController::class, 'page'])->name('admin.settings');
35 35
     //products
36
-    Route::get('/admin/prodotto/crea-prodotto',[AdminNewProductController::class,'page'])->name('admin.product.new');
37
-    Route::get('/admin/prodotti',[AdminProductsListController::class,'page'])->name('admin.product.list');
38
-    Route::get('/admin/prodotto/crea-singolo-prodotto',[AdminNewSingleProductController::class,'page'])->name('admin.new.single.product');
39
-    Route::get('/admin/prodotto-variante/{id_product}',[AdminNewProductVariationController::class,'page'])->name('admin.product.new.variante');
36
+    Route::get('/admin/prodotto/crea-prodotto', [AdminNewProductController::class, 'page'])->name('admin.product.new');
37
+    Route::get('/admin/prodotti', [AdminProductsListController::class, 'page'])->name('admin.product.list');
38
+    Route::get('/admin/prodotto/crea-singolo-prodotto', [AdminNewSingleProductController::class, 'page'])->name('admin.new.single.product');
39
+    Route::get('/admin/prodotto-variante/{id_product}', [AdminNewProductVariationController::class, 'page'])->name('admin.product.new.variante');
40 40
     //orders
41
-    Route::get('/admin/ordini',[AdminOrdersController::class,'page'])->name('admin.orders.list');
41
+    Route::get('/admin/ordini', [AdminOrdersController::class, 'page'])->name('admin.orders.list');
42 42
 
43 43
 
44 44
 
45 45
     /*****************
46 46
      *-----POST------*
47 47
      *****************/
48
-    Route::post('/admin/post/get/categories/tree',[AdminCategoryController::class,'getStructureCategories'])->name('admin.post.get.categories.tree');
49
-    Route::post('/admin/post/get/categories',[AdminCategoryController::class,'getCategories'])->name('admin.post.get.categories');
50
-    Route::post('/admin/post/create-new-category',[AdminCategoryController::class,'setNewCategory'])->name('admin.post.create.new.category');
48
+    Route::post('/admin/post/get/categories/tree', [AdminCategoryController::class, 'getStructureCategories'])->name('admin.post.get.categories.tree');
49
+    Route::post('/admin/post/get/categories', [AdminCategoryController::class, 'getCategories'])->name('admin.post.get.categories');
50
+    Route::post('/admin/post/create-new-category', [AdminCategoryController::class, 'setNewCategory'])->name('admin.post.create.new.category');
51 51
 
52 52
     //details
53
-    Route::post('/admin/post/create/detail',[AdminDetailController::class,'setNewDetail'])->name('admin.post.create.detail');
54
-    Route::post('/admin/post/get/details',[AdminDetailController::class,'getDetails'])->name('admin.post.get.details');
53
+    Route::post('/admin/post/create/detail', [AdminDetailController::class, 'setNewDetail'])->name('admin.post.create.detail');
54
+    Route::post('/admin/post/get/details', [AdminDetailController::class, 'getDetails'])->name('admin.post.get.details');
55 55
 
56 56
     //configuration
57
-    Route::post('/admin/post/create/configuration',[AdminConfigurationFieldController::class,'setNewConfiguration'])->name('admin.post.create.configuration');
58
-    Route::post('/admin/post/get/configuration',[AdminConfigurationFieldController::class,'getConfigurationFields'])->name('admin.post.get.configuration');
57
+    Route::post('/admin/post/create/configuration', [AdminConfigurationFieldController::class, 'setNewConfiguration'])->name('admin.post.create.configuration');
58
+    Route::post('/admin/post/get/configuration', [AdminConfigurationFieldController::class, 'getConfigurationFields'])->name('admin.post.get.configuration');
59 59
 
60 60
     //product
61
-    Route::post('/admin/prodotto/crea-prodotto',[AdminNewProductController::class,'createNewProduct'])->name('admin.post.product.new');
62
-    Route::post('/admin/prodotto/crea-variante-prodotto',[AdminNewProductVariationController::class,'createNewVariation'])->name('admin.post.product.variation.new');
63
-    Route::post('/admin/prodotto/crea-singolo-prodotto',[AdminNewSingleProductController::class,'createNewSingleProduct'])->name('admin.post.new.single.product');
61
+    Route::post('/admin/prodotto/crea-prodotto', [AdminNewProductController::class, 'createNewProduct'])->name('admin.post.product.new');
62
+    Route::post('/admin/prodotto/crea-variante-prodotto', [AdminNewProductVariationController::class, 'createNewVariation'])->name('admin.post.product.variation.new');
63
+    Route::post('/admin/prodotto/crea-singolo-prodotto', [AdminNewSingleProductController::class, 'createNewSingleProduct'])->name('admin.post.new.single.product');
64 64
 
65 65
 
66 66
     //refresh
67
-    Route::get('/admin/update',[AdminUpdatePackageController::class,'update'])->name('admin.updatepackage');
67
+    Route::get('/admin/update', [AdminUpdatePackageController::class, 'update'])->name('admin.updatepackage');
68 68
 
69 69
 });
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.