Test Failed
Push — master ( 1a75c8...de8515 )
by Gianluca
06:01
created
src/Models/Order.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -14,21 +14,21 @@
 block discarded – undo
14 14
 {
15 15
     use HasFactory;
16 16
 
17
-    protected $dates = ["created_at","updated_at"];
17
+    protected $dates = ["created_at", "updated_at"];
18 18
 
19
-    public function status(){
20
-        return $this->belongsTo(OrderStatus::class,'status_id');
19
+    public function status() {
20
+        return $this->belongsTo(OrderStatus::class, 'status_id');
21 21
     }
22 22
 
23
-    public function typePayment(){
24
-        return $this->belongsTo(TypePayment::class,'payment_type_id');
23
+    public function typePayment() {
24
+        return $this->belongsTo(TypePayment::class, 'payment_type_id');
25 25
     }
26 26
 
27
-    public function user(){
28
-        return $this->belongsTo(User::class,'user_id');
27
+    public function user() {
28
+        return $this->belongsTo(User::class, 'user_id');
29 29
     }
30 30
 
31
-    public function products(){
32
-        return $this->belongsToMany(ProductItem::class,'product_order','order_id','product_item_id')->withPivot('number_products');
31
+    public function products() {
32
+        return $this->belongsToMany(ProductItem::class, 'product_order', 'order_id', 'product_item_id')->withPivot('number_products');
33 33
     }
34 34
 }
Please login to merge, or discard this patch.
src/Models/Cart.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -12,15 +12,15 @@
 block discarded – undo
12 12
 {
13 13
     use HasFactory;
14 14
     protected $table = 'cart';
15
-    protected $dates = ["created_at","updated_at"];
15
+    protected $dates = ["created_at", "updated_at"];
16 16
 
17 17
 
18
-    public function user(){
19
-        return $this->belongsTo(User::class,'user_id');
18
+    public function user() {
19
+        return $this->belongsTo(User::class, 'user_id');
20 20
     }
21 21
 
22
-    static function emptyCart(){
23
-        self::where('user_id',Auth::user()->id)->delete();
22
+    static function emptyCart() {
23
+        self::where('user_id', Auth::user()->id)->delete();
24 24
     }
25 25
 
26 26
 
Please login to merge, or discard this patch.
database/migrations/2020_12_07_082433_create_order_products.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
      */
14 14
     public function up()
15 15
     {
16
-        Schema::create('product_order', function (Blueprint $table) {
16
+        Schema::create('product_order', function(Blueprint $table) {
17 17
             $table->id();
18 18
             $table->unsignedBigInteger('order_id');
19 19
             $table->unsignedBigInteger('product_item_id');
Please login to merge, or discard this patch.
database/migrations/2021_10_12_000000_modify_users_table.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
      */
14 14
     public function up()
15 15
     {
16
-        Schema::table('users', function (Blueprint $table) {
16
+        Schema::table('users', function(Blueprint $table) {
17 17
             $table->string('name')->nullable()->change();
18 18
             $table->string('first_name')->nullable();
19 19
             $table->string('last_name')->nullable();
Please login to merge, or discard this patch.
src/routes.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 use Mongi\Mongicommerce\Http\Controllers\admin\AdminNewProductVariationController;
28 28
 
29 29
 
30
-Route::group(['middleware' => ['web']], function () {
30
+Route::group(['middleware' => ['web']], function() {
31 31
     /*****************
32 32
      *-----SHOP------*
33 33
      *****************/
@@ -49,27 +49,27 @@  discard block
 block discarded – undo
49 49
     Route::get('/page/shop/user/settings', [ShopUserController::class, 'page'])->name('shop.user.settings');
50 50
 
51 51
 
52
-    Route::get('/shop/{id?}',[ShopController::class,'page'])->name('shop');
53
-    Route::get('/prodotto/{id}/{item_id?}',[ShopSingleProductController::class,'page'])->name('shop.single.product');
54
-    Route::get('page/shop/cart/',[ShopCartController::class,'page'])->name('shop.cart');
55
-    Route::get('page/shop/summary/',[ShopSummaryController::class,'page'])->name('shop.summary');
56
-    Route::get('page/shop/shipment/',[ShopShipmentController::class,'page'])->name('shop.shipment');
57
-    Route::get('page/shop/checkout/',[ShopCheckoutController::class,'page'])->name('shop.checkout');
58
-    Route::get('page/shop/payment/',[ShopPaymentController::class,'page'])->name('shop.payment');
52
+    Route::get('/shop/{id?}', [ShopController::class, 'page'])->name('shop');
53
+    Route::get('/prodotto/{id}/{item_id?}', [ShopSingleProductController::class, 'page'])->name('shop.single.product');
54
+    Route::get('page/shop/cart/', [ShopCartController::class, 'page'])->name('shop.cart');
55
+    Route::get('page/shop/summary/', [ShopSummaryController::class, 'page'])->name('shop.summary');
56
+    Route::get('page/shop/shipment/', [ShopShipmentController::class, 'page'])->name('shop.shipment');
57
+    Route::get('page/shop/checkout/', [ShopCheckoutController::class, 'page'])->name('shop.checkout');
58
+    Route::get('page/shop/payment/', [ShopPaymentController::class, 'page'])->name('shop.payment');
59 59
 
60 60
 
61 61
 
62
-    Route::post('/shop/get/product-information',[ShopShowVariationProductController::class,'getData'])->name('shop.get.product.information');
63
-    Route::post('/shop/addtocart',[ShopCartController::class,'addToCart'])->name('shop.addtocart');
64
-    Route::post('/shop/getcartelements',[ShopCartController::class,'getCartElements'])->name('shop.getcartelements');
62
+    Route::post('/shop/get/product-information', [ShopShowVariationProductController::class, 'getData'])->name('shop.get.product.information');
63
+    Route::post('/shop/addtocart', [ShopCartController::class, 'addToCart'])->name('shop.addtocart');
64
+    Route::post('/shop/getcartelements', [ShopCartController::class, 'getCartElements'])->name('shop.getcartelements');
65 65
 
66
-    Route::post('/shop/getcartproducts/',[ShopCartController::class,'getCartProducts'])->name('getcartproducts');
67
-    Route::post('/shop/increment_number_product_in_cart/',[ShopCartController::class,'incrementOrDecrementElementInCart'])->name('increment_number_product_in_cart');
68
-    Route::post('/shop/delete_from_cart',[ShopCartController::class,'deleteFromCart'])->name('delete_from_cart');
69
-    Route::post('/shop/save_cache_details_order',[ShopCheckoutController::class,'saveDetailsInSession'])->name('save_cache_details_order');
70
-    Route::post('/shop/gotocheckout',[ShopShipmentController::class,'goToCheckout'])->name('shop.gotocheckout');
71
-    Route::post('/shop/pay',[ShopPaymentController::class,'pay'])->name('shop.pay');
72
-    Route::post('/shop/normalpayment',[ShopPaymentController::class,'normalPayment'])->name('shop.normalpayment');
66
+    Route::post('/shop/getcartproducts/', [ShopCartController::class, 'getCartProducts'])->name('getcartproducts');
67
+    Route::post('/shop/increment_number_product_in_cart/', [ShopCartController::class, 'incrementOrDecrementElementInCart'])->name('increment_number_product_in_cart');
68
+    Route::post('/shop/delete_from_cart', [ShopCartController::class, 'deleteFromCart'])->name('delete_from_cart');
69
+    Route::post('/shop/save_cache_details_order', [ShopCheckoutController::class, 'saveDetailsInSession'])->name('save_cache_details_order');
70
+    Route::post('/shop/gotocheckout', [ShopShipmentController::class, 'goToCheckout'])->name('shop.gotocheckout');
71
+    Route::post('/shop/pay', [ShopPaymentController::class, 'pay'])->name('shop.pay');
72
+    Route::post('/shop/normalpayment', [ShopPaymentController::class, 'normalPayment'])->name('shop.normalpayment');
73 73
 
74 74
 
75 75
 
@@ -79,44 +79,44 @@  discard block
 block discarded – undo
79 79
     /*****************
80 80
      *------GET------*
81 81
      *****************/
82
-    Route::get('/admin/dashboard',[DashboardController::class,'page'])->name('admin.dashboard');
83
-    Route::get('/admin/categorie/',[AdminCategoryController::class,'page'])->name('admin.category.new');
84
-    Route::get('/admin/dettagli',[AdminDetailController::class,'page'])->name('admin.details');
85
-    Route::get('/admin/settings',[AdminSettingsController::class,'page'])->name('admin.settings');
82
+    Route::get('/admin/dashboard', [DashboardController::class, 'page'])->name('admin.dashboard');
83
+    Route::get('/admin/categorie/', [AdminCategoryController::class, 'page'])->name('admin.category.new');
84
+    Route::get('/admin/dettagli', [AdminDetailController::class, 'page'])->name('admin.details');
85
+    Route::get('/admin/settings', [AdminSettingsController::class, 'page'])->name('admin.settings');
86 86
     //products
87
-    Route::get('/admin/prodotto/crea-prodotto',[AdminNewProductController::class,'page'])->name('admin.product.new');
88
-    Route::get('/admin/prodotti',[AdminProductsListController::class,'page'])->name('admin.product.list');
89
-    Route::get('/admin/prodotto/crea-singolo-prodotto',[AdminNewSingleProductController::class,'page'])->name('admin.new.single.product');
90
-    Route::get('/admin/prodotto-variante/{id_product}',[AdminNewProductVariationController::class,'page'])->name('admin.product.new.variante');
87
+    Route::get('/admin/prodotto/crea-prodotto', [AdminNewProductController::class, 'page'])->name('admin.product.new');
88
+    Route::get('/admin/prodotti', [AdminProductsListController::class, 'page'])->name('admin.product.list');
89
+    Route::get('/admin/prodotto/crea-singolo-prodotto', [AdminNewSingleProductController::class, 'page'])->name('admin.new.single.product');
90
+    Route::get('/admin/prodotto-variante/{id_product}', [AdminNewProductVariationController::class, 'page'])->name('admin.product.new.variante');
91 91
     //orders
92
-    Route::get('/admin/ordini',[AdminOrdersController::class,'page'])->name('admin.orders.list');
93
-    Route::get('/admin/ordine/{order_id}',[AdminOrderDetailsController::class,'page'])->name('admin.order');
94
-     Route::get('/admin/clienti',[AdminClientsController::class,'page'])->name('admin.clients');
92
+    Route::get('/admin/ordini', [AdminOrdersController::class, 'page'])->name('admin.orders.list');
93
+    Route::get('/admin/ordine/{order_id}', [AdminOrderDetailsController::class, 'page'])->name('admin.order');
94
+     Route::get('/admin/clienti', [AdminClientsController::class, 'page'])->name('admin.clients');
95 95
 
96 96
 
97 97
 
98 98
     /*****************
99 99
      *-----POST------*
100 100
      *****************/
101
-    Route::post('/admin/post/get/categories/tree',[AdminCategoryController::class,'getStructureCategories'])->name('admin.post.get.categories.tree');
102
-    Route::post('/admin/post/get/categories',[AdminCategoryController::class,'getCategories'])->name('admin.post.get.categories');
103
-    Route::post('/admin/post/create-new-category',[AdminCategoryController::class,'setNewCategory'])->name('admin.post.create.new.category');
101
+    Route::post('/admin/post/get/categories/tree', [AdminCategoryController::class, 'getStructureCategories'])->name('admin.post.get.categories.tree');
102
+    Route::post('/admin/post/get/categories', [AdminCategoryController::class, 'getCategories'])->name('admin.post.get.categories');
103
+    Route::post('/admin/post/create-new-category', [AdminCategoryController::class, 'setNewCategory'])->name('admin.post.create.new.category');
104 104
 
105 105
     //details
106
-    Route::post('/admin/post/create/detail',[AdminDetailController::class,'setNewDetail'])->name('admin.post.create.detail');
107
-    Route::post('/admin/post/get/details',[AdminDetailController::class,'getDetails'])->name('admin.post.get.details');
106
+    Route::post('/admin/post/create/detail', [AdminDetailController::class, 'setNewDetail'])->name('admin.post.create.detail');
107
+    Route::post('/admin/post/get/details', [AdminDetailController::class, 'getDetails'])->name('admin.post.get.details');
108 108
 
109 109
     //configuration
110
-    Route::post('/admin/post/create/configuration',[AdminConfigurationFieldController::class,'setNewConfiguration'])->name('admin.post.create.configuration');
111
-    Route::post('/admin/post/get/configuration',[AdminConfigurationFieldController::class,'getConfigurationFields'])->name('admin.post.get.configuration');
110
+    Route::post('/admin/post/create/configuration', [AdminConfigurationFieldController::class, 'setNewConfiguration'])->name('admin.post.create.configuration');
111
+    Route::post('/admin/post/get/configuration', [AdminConfigurationFieldController::class, 'getConfigurationFields'])->name('admin.post.get.configuration');
112 112
 
113 113
     //product
114
-    Route::post('/admin/prodotto/crea-prodotto',[AdminNewProductController::class,'createNewProduct'])->name('admin.post.product.new');
115
-    Route::post('/admin/prodotto/crea-variante-prodotto',[AdminNewProductVariationController::class,'createNewVariation'])->name('admin.post.product.variation.new');
116
-    Route::post('/admin/prodotto/crea-singolo-prodotto',[AdminNewSingleProductController::class,'createNewSingleProduct'])->name('admin.post.new.single.product');
114
+    Route::post('/admin/prodotto/crea-prodotto', [AdminNewProductController::class, 'createNewProduct'])->name('admin.post.product.new');
115
+    Route::post('/admin/prodotto/crea-variante-prodotto', [AdminNewProductVariationController::class, 'createNewVariation'])->name('admin.post.product.variation.new');
116
+    Route::post('/admin/prodotto/crea-singolo-prodotto', [AdminNewSingleProductController::class, 'createNewSingleProduct'])->name('admin.post.new.single.product');
117 117
 
118 118
 
119 119
     //refresh
120
-    Route::get('/admin/update',[AdminUpdatePackageController::class,'update'])->name('admin.updatepackage');
120
+    Route::get('/admin/update', [AdminUpdatePackageController::class, 'update'])->name('admin.updatepackage');
121 121
 
122 122
 });
Please login to merge, or discard this patch.
src/MongicommerceServiceProvider.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
     public function boot()
22 22
     {
23 23
 
24
-        Blade::directive('money', function ($amount){
24
+        Blade::directive('money', function($amount) {
25 25
             #return $fmt->formatCurrency($amount,"EUR");
26 26
             /*return "<?= $fmt->formatCurrency($amount,'EUR'); ?>";*/
27 27
             return "<?= abs($amount) > 1000 ? '€ ' .number_format($amount, 0, ',', '.') : '€ ' . number_format($amount, 2, ',', '.') ?>";
@@ -35,12 +35,12 @@  discard block
 block discarded – undo
35 35
         $this->loadMigrationsFrom(__DIR__.'/../database/migrations');
36 36
         $this->loadRoutesFrom(__DIR__.'/routes.php');
37 37
 
38
-        if(Schema::hasTable('admin_settings')){
38
+        if (Schema::hasTable('admin_settings')) {
39 39
             //inject global information into views
40 40
             View::share('mongicommerce', AdminSetting::first());
41 41
         }
42 42
 
43
-        if(Schema::hasTable('categories')){
43
+        if (Schema::hasTable('categories')) {
44 44
             //inject global information into views
45 45
             View::share('categories', Template::getStructureCategories());
46 46
         }
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
         $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'mongicommerce');
104 104
 
105 105
         // Register the main class to use with the facade
106
-        $this->app->singleton('mongicommerce', function () {
106
+        $this->app->singleton('mongicommerce', function() {
107 107
             return new Mongicommerce;
108 108
         });
109 109
     }
Please login to merge, or discard this patch.
src/Http/Controllers/shop/ShopSingleProductController.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -7,17 +7,17 @@
 block discarded – undo
7 7
 
8 8
 class ShopSingleProductController extends Controller
9 9
 {
10
-     public function page($id,$product_item_id = null){
10
+     public function page($id, $product_item_id = null) {
11 11
          $product = Product::find($id);
12
-         if($product_item_id == null){
13
-             return redirect()->route('shop.single.product',[$product->id,$product->items->first()->id]);
12
+         if ($product_item_id == null) {
13
+             return redirect()->route('shop.single.product', [$product->id, $product->items->first()->id]);
14 14
          }
15 15
          
16
-         $details_fields = Template::getDetailsFields($product,$product_item_id);
16
+         $details_fields = Template::getDetailsFields($product, $product_item_id);
17 17
          $configuration_fields = Template::getConfigurationFields($product_item_id);
18 18
          $btn_cart = Template::buttonCart($product_item_id);
19 19
          $price = Product::getPrice($product_item_id);
20 20
          $image = Product::getImage($product_item_id);
21
-         return view('mongicommerce.pages.single-product',compact('product','details_fields','configuration_fields','btn_cart','price','image'));
21
+         return view('mongicommerce.pages.single-product', compact('product', 'details_fields', 'configuration_fields', 'btn_cart', 'price', 'image'));
22 22
      }
23 23
 }
Please login to merge, or discard this patch.
src/Models/Product.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -14,25 +14,25 @@
 block discarded – undo
14 14
 {
15 15
     use HasFactory;
16 16
 
17
-    protected $dates = ["created_at","updated_at"];
17
+    protected $dates = ["created_at", "updated_at"];
18 18
 
19
-    public function items(){
19
+    public function items() {
20 20
         return $this->hasMany(ProductItem::class);
21 21
     }
22 22
 
23
-    public function category(){
23
+    public function category() {
24 24
         return $this->belongsTo(Category::class);
25 25
     }
26 26
 
27
-    public function details(){
28
-        return $this->hasManyThrough(ProductItemDetail::class,ProductItem::class);
27
+    public function details() {
28
+        return $this->hasManyThrough(ProductItemDetail::class, ProductItem::class);
29 29
     }
30 30
 
31
-    public static function getPrice($product_item_id){
31
+    public static function getPrice($product_item_id) {
32 32
         return ProductItem::find($product_item_id)->price;
33 33
     }
34 34
 
35
-    public static function getImage($product_item_id){
35
+    public static function getImage($product_item_id) {
36 36
         return ProductItem::find($product_item_id)->image;
37 37
     }
38 38
 
Please login to merge, or discard this patch.
src/Libraries/Template.php 1 patch
Spacing   +36 added lines, -36 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,
@@ -44,10 +44,10 @@  discard block
 block discarded – undo
44 44
     }
45 45
 
46 46
     public static function  getCategoryTree($parent_id = null, $spacing = '', $tree_array = array()) {
47
-        $categories = Category::select('id', 'name', 'parent_id')->where('parent_id' ,'=', $parent_id)->orderBy('parent_id')->get();
48
-        foreach ($categories as $item){
49
-            $tree_array[] = ['id' => $item->id, 'name' =>$spacing . $item->name] ;
50
-            $tree_array = self::getCategoryTree($item->id, $spacing . '- ', $tree_array);
47
+        $categories = Category::select('id', 'name', 'parent_id')->where('parent_id', '=', $parent_id)->orderBy('parent_id')->get();
48
+        foreach ($categories as $item) {
49
+            $tree_array[] = ['id' => $item->id, 'name' =>$spacing.$item->name];
50
+            $tree_array = self::getCategoryTree($item->id, $spacing.'- ', $tree_array);
51 51
         }
52 52
         return $tree_array;
53 53
     }
@@ -56,34 +56,34 @@  discard block
 block discarded – undo
56 56
      * @param Int $id
57 57
      * @return Product
58 58
      */
59
-    public static function getProducts($id = null){
60
-        if($id === null){
59
+    public static function getProducts($id = null) {
60
+        if ($id === null) {
61 61
             $products = Product::all();
62
-        }else{
62
+        } else {
63 63
             $products = Category::find($id)->products;
64 64
         }
65 65
         return $products;
66 66
     }
67 67
 
68
-    public static function getDetailsFields(Product $product,$product_item_id){
68
+    public static function getDetailsFields(Product $product, $product_item_id) {
69 69
         $element = '<div class="row col">';
70 70
 
71
-        foreach($product->details->groupBy('product_detail_id') as $key => $details){
71
+        foreach ($product->details->groupBy('product_detail_id') as $key => $details) {
72 72
 
73
-            $element.= self::generateDetailHtml(Detail::find($key),$details->groupBy('product_detail_value_id'),$product->id,$product_item_id);
73
+            $element .= self::generateDetailHtml(Detail::find($key), $details->groupBy('product_detail_value_id'), $product->id, $product_item_id);
74 74
         }
75
-        $element.= '<p class="show_error_product" style="color: red; display: none;">Prodotto non disponibile</p>';
75
+        $element .= '<p class="show_error_product" style="color: red; display: none;">Prodotto non disponibile</p>';
76 76
         $element .= '</div>';
77 77
         return $element;
78 78
     }
79 79
 
80
-    public static function generateHtmlField($type,$value,$label){
81
-        if($type !== 'textarea'){
80
+    public static function generateHtmlField($type, $value, $label) {
81
+        if ($type !== 'textarea') {
82 82
             $html = '';
83 83
             $html .= "<label>{$label}</label>";
84 84
             $html .= "<input disabled class='form-control' type='{$type}' value='{$value}'>";
85 85
             return $html;
86
-        }else{
86
+        } else {
87 87
             $html = '';
88 88
             $html .= "<label>{$label}</label>";
89 89
             $html .= "<textarea disabled class='form-control'>{$value}</textarea>";
@@ -91,40 +91,40 @@  discard block
 block discarded – undo
91 91
         }
92 92
     }
93 93
 
94
-    public static function getConfigurationFields($product_item_id){
95
-        $configurationFields = ProductConfigurationField::where('product_item_id',$product_item_id)->get();
94
+    public static function getConfigurationFields($product_item_id) {
95
+        $configurationFields = ProductConfigurationField::where('product_item_id', $product_item_id)->get();
96 96
         $element = '<div class="col row">';
97
-        foreach ($configurationFields as $field){
98
-                $element .= self::generateHtmlField($field->field->type,$field->value,$field->field->name);
97
+        foreach ($configurationFields as $field) {
98
+                $element .= self::generateHtmlField($field->field->type, $field->value, $field->field->name);
99 99
 
100 100
             }
101 101
             $element .= '</div>';
102 102
         return $element;
103 103
     }
104 104
 
105
-    public static function buttonCart($product_item_id){
105
+    public static function buttonCart($product_item_id) {
106 106
         return "<button onclick='addToCart(this)' data-product_item_id='{$product_item_id}' class='btn btn-primary mt-3'>Salva nel carrello</button>";
107 107
     }
108 108
 
109
-    public static function generateDetailHtml($detail,$values,$product_id,$product_item_id){
109
+    public static function generateDetailHtml($detail, $values, $product_id, $product_item_id) {
110 110
 
111 111
         $type = $detail->type;
112 112
         $html = '';
113
-        if($type === 'select'){
113
+        if ($type === 'select') {
114 114
             $html = '<label>'.$detail->name.'</label>';
115
-            $html .= '<select onchange="getVariationProduct()" data-product_id="'.$product_id.'" data-detail_id="'.$detail->id .'" class="form-control mongifield_into_product">';
115
+            $html .= '<select onchange="getVariationProduct()" data-product_id="'.$product_id.'" data-detail_id="'.$detail->id.'" class="form-control mongifield_into_product">';
116 116
             $selected = '';
117 117
 
118
-            $details = ProductItemDetail::where('product_item_id',$product_item_id)->get();
118
+            $details = ProductItemDetail::where('product_item_id', $product_item_id)->get();
119 119
             $filter = [];
120
-            foreach ($details as $_detail){
120
+            foreach ($details as $_detail) {
121 121
                 $filter[$_detail->product_detail_id] = $_detail->product_detail_value_id;
122 122
             }
123
-            foreach ($values as $detail_value_id =>$value){
124
-                if(isset($filter[$detail->id])){
125
-                    if($filter[$detail->id] == $detail_value_id){
123
+            foreach ($values as $detail_value_id =>$value) {
124
+                if (isset($filter[$detail->id])) {
125
+                    if ($filter[$detail->id] == $detail_value_id) {
126 126
                         $selected = 'selected';
127
-                    }else{
127
+                    } else {
128 128
                         $selected = '';
129 129
                     }
130 130
                 }
@@ -137,12 +137,12 @@  discard block
 block discarded – undo
137 137
         return $html;
138 138
     }
139 139
 
140
-    public static function MoveSessionToCart($user_id){
140
+    public static function MoveSessionToCart($user_id) {
141 141
         $user = User::find($user_id);
142 142
         $elements_in_cart = session('cart');
143
-        if(!empty($elements_in_cart)){
144
-            if(Cart::where('user_id',$user->id)->count() <= 0){
145
-                foreach($elements_in_cart as $product_id => $count){
143
+        if (!empty($elements_in_cart)) {
144
+            if (Cart::where('user_id', $user->id)->count() <= 0) {
145
+                foreach ($elements_in_cart as $product_id => $count) {
146 146
                     $cart = new Cart();
147 147
                     $cart->user_id = $user->id;
148 148
                     $cart->product_item_id = $product_id;
Please login to merge, or discard this patch.