@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | public function boot() |
| 22 | 22 | { |
| 23 | - Blade::directive('money', function ($amount){ |
|
| 23 | + Blade::directive('money', function($amount) { |
|
| 24 | 24 | #return $fmt->formatCurrency($amount,"EUR"); |
| 25 | 25 | /*return "<?= $fmt->formatCurrency($amount,'EUR'); ?>";*/ |
| 26 | 26 | return "<?= abs($amount) > 1000 ? '€ ' .number_format($amount, 0, ',', '.') : '€ ' . number_format($amount, 2, ',', '.') ?>"; |
@@ -34,12 +34,12 @@ discard block |
||
| 34 | 34 | $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); |
| 35 | 35 | $this->loadRoutesFrom(__DIR__.'/routes.php'); |
| 36 | 36 | |
| 37 | - if(Schema::hasTable('admin_settings')){ |
|
| 37 | + if (Schema::hasTable('admin_settings')) { |
|
| 38 | 38 | //inject global information into views |
| 39 | 39 | View::share('mongicommerce', AdminSetting::first()); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - if(Schema::hasTable('categories')){ |
|
| 42 | + if (Schema::hasTable('categories')) { |
|
| 43 | 43 | //inject global information into views |
| 44 | 44 | View::share('categories', Template::getStructureCategories()); |
| 45 | 45 | } |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | if ($this->app->runningInConsole()) { |
| 49 | 49 | |
| 50 | 50 | $config_file = config_path('mongicommerce.php'); |
| 51 | - if(file_exists($config_file)){ |
|
| 51 | + if (file_exists($config_file)) { |
|
| 52 | 52 | File::delete($config_file); |
| 53 | 53 | } |
| 54 | 54 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | __DIR__.'/../config/config.php' => config_path('mongicommerce.php'), |
| 58 | 58 | ], 'config'); |
| 59 | 59 | |
| 60 | - if(file_exists(resource_path('/views/mongicommerce'))){ |
|
| 60 | + if (file_exists(resource_path('/views/mongicommerce'))) { |
|
| 61 | 61 | File::deleteDirectory(resource_path('/views/mongicommerce')); |
| 62 | 62 | } |
| 63 | 63 | // Publishing the views. |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | __DIR__.'/../resources/views/shop' => resource_path('/views/mongicommerce'), |
| 66 | 66 | ], 'views'); |
| 67 | 67 | |
| 68 | - if(file_exists(public_path('/mongicommerce/template'))){ |
|
| 68 | + if (file_exists(public_path('/mongicommerce/template'))) { |
|
| 69 | 69 | File::deleteDirectory(public_path('/mongicommerce/template')); |
| 70 | 70 | } |
| 71 | 71 | // Publishing assets. |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'mongicommerce'); |
| 97 | 97 | |
| 98 | 98 | // Register the main class to use with the facade |
| 99 | - $this->app->singleton('mongicommerce', function () { |
|
| 99 | + $this->app->singleton('mongicommerce', function() { |
|
| 100 | 100 | return new Mongicommerce; |
| 101 | 101 | }); |
| 102 | 102 | } |
@@ -19,69 +19,69 @@ |
||
| 19 | 19 | use Mongi\Mongicommerce\Http\Controllers\shop\ShopSingleProductController; |
| 20 | 20 | use Mongi\Mongicommerce\Http\Controllers\shop\ShopSummaryController; |
| 21 | 21 | |
| 22 | -Route::group(['middleware' => ['web']], function () { |
|
| 22 | +Route::group(['middleware' => ['web']], function() { |
|
| 23 | 23 | /***************** |
| 24 | 24 | *-----SHOP------* |
| 25 | 25 | *****************/ |
| 26 | 26 | |
| 27 | - Route::get('/shop/{id?}',[ShopController::class,'page'])->name('shop'); |
|
| 28 | - Route::get('/prodotto/{id}/{item_id?}',[ShopSingleProductController::class,'page'])->name('shop.single.product'); |
|
| 29 | - Route::get('page/shop/cart/',[ShopCartController::class,'page'])->name('shop.cart'); |
|
| 30 | - Route::get('page/shop/summary/',[ShopSummaryController::class,'page'])->name('shop.summary'); |
|
| 31 | - Route::get('page/shop/shipment/',[ShopShipmentController::class,'page'])->name('shop.shipment'); |
|
| 32 | - Route::get('page/shop/payment/',[ShopPaymentController::class,'page'])->name('shop.payment'); |
|
| 27 | + Route::get('/shop/{id?}', [ShopController::class, 'page'])->name('shop'); |
|
| 28 | + Route::get('/prodotto/{id}/{item_id?}', [ShopSingleProductController::class, 'page'])->name('shop.single.product'); |
|
| 29 | + Route::get('page/shop/cart/', [ShopCartController::class, 'page'])->name('shop.cart'); |
|
| 30 | + Route::get('page/shop/summary/', [ShopSummaryController::class, 'page'])->name('shop.summary'); |
|
| 31 | + Route::get('page/shop/shipment/', [ShopShipmentController::class, 'page'])->name('shop.shipment'); |
|
| 32 | + Route::get('page/shop/payment/', [ShopPaymentController::class, 'page'])->name('shop.payment'); |
|
| 33 | 33 | |
| 34 | 34 | |
| 35 | - Route::post('/shop/get/product-information',[ShopShowVariationProductController::class,'getData'])->name('shop.get.product.information'); |
|
| 36 | - Route::post('/shop/addtocart',[ShopCartController::class,'addToCart'])->name('shop.addtocart'); |
|
| 37 | - Route::post('/shop/getcartelements',[ShopCartController::class,'getCartElements'])->name('shop.getcartelements'); |
|
| 35 | + Route::post('/shop/get/product-information', [ShopShowVariationProductController::class, 'getData'])->name('shop.get.product.information'); |
|
| 36 | + Route::post('/shop/addtocart', [ShopCartController::class, 'addToCart'])->name('shop.addtocart'); |
|
| 37 | + Route::post('/shop/getcartelements', [ShopCartController::class, 'getCartElements'])->name('shop.getcartelements'); |
|
| 38 | 38 | |
| 39 | - Route::post('/shop/getcartproducts/',[ShopCartController::class,'getCartProducts'])->name('getcartproducts'); |
|
| 40 | - Route::post('shop/increment_number_product_in_cart/',[ShopCartController::class,'incrementOrDecrementElementInCart'])->name('increment_number_product_in_cart'); |
|
| 41 | - Route::post('/shop/delete_from_cart',[ShopCartController::class,'deleteFromCart'])->name('delete_from_cart'); |
|
| 42 | - Route::post('/shop/save_cache_details_order',[ShopCheckoutController::class,'saveDetailsInSession'])->name('save_cache_details_order'); |
|
| 39 | + Route::post('/shop/getcartproducts/', [ShopCartController::class, 'getCartProducts'])->name('getcartproducts'); |
|
| 40 | + Route::post('shop/increment_number_product_in_cart/', [ShopCartController::class, 'incrementOrDecrementElementInCart'])->name('increment_number_product_in_cart'); |
|
| 41 | + Route::post('/shop/delete_from_cart', [ShopCartController::class, 'deleteFromCart'])->name('delete_from_cart'); |
|
| 42 | + Route::post('/shop/save_cache_details_order', [ShopCheckoutController::class, 'saveDetailsInSession'])->name('save_cache_details_order'); |
|
| 43 | 43 | |
| 44 | 44 | |
| 45 | - Route::get('page/shop/checkout/',[ShopCheckoutController::class,'page'])->name('shop.checkout'); |
|
| 45 | + Route::get('page/shop/checkout/', [ShopCheckoutController::class, 'page'])->name('shop.checkout'); |
|
| 46 | 46 | /***************** |
| 47 | 47 | *------GET------* |
| 48 | 48 | *****************/ |
| 49 | - Route::get('/admin/dashboard',[DashboardController::class,'page'])->name('admin.dashboard'); |
|
| 50 | - Route::get('/admin/categorie/',[AdminCategoryController::class,'page'])->name('admin.category.new'); |
|
| 51 | - Route::get('/admin/dettagli',[AdminDetailController::class,'page'])->name('admin.details'); |
|
| 52 | - Route::get('/admin/settings',[AdminSettingsController::class,'page'])->name('admin.settings'); |
|
| 49 | + Route::get('/admin/dashboard', [DashboardController::class, 'page'])->name('admin.dashboard'); |
|
| 50 | + Route::get('/admin/categorie/', [AdminCategoryController::class, 'page'])->name('admin.category.new'); |
|
| 51 | + Route::get('/admin/dettagli', [AdminDetailController::class, 'page'])->name('admin.details'); |
|
| 52 | + Route::get('/admin/settings', [AdminSettingsController::class, 'page'])->name('admin.settings'); |
|
| 53 | 53 | //products |
| 54 | - Route::get('/admin/prodotto/crea-prodotto',[AdminNewProductController::class,'page'])->name('admin.product.new'); |
|
| 55 | - Route::get('/admin/prodotti',[AdminProductsListController::class,'page'])->name('admin.product.list'); |
|
| 56 | - Route::get('/admin/prodotto/crea-singolo-prodotto',[AdminNewSingleProductController::class,'page'])->name('admin.new.single.product'); |
|
| 57 | - Route::get('/admin/prodotto-variante/{id_product}',[AdminNewProductVariationController::class,'page'])->name('admin.product.new.variante'); |
|
| 54 | + Route::get('/admin/prodotto/crea-prodotto', [AdminNewProductController::class, 'page'])->name('admin.product.new'); |
|
| 55 | + Route::get('/admin/prodotti', [AdminProductsListController::class, 'page'])->name('admin.product.list'); |
|
| 56 | + Route::get('/admin/prodotto/crea-singolo-prodotto', [AdminNewSingleProductController::class, 'page'])->name('admin.new.single.product'); |
|
| 57 | + Route::get('/admin/prodotto-variante/{id_product}', [AdminNewProductVariationController::class, 'page'])->name('admin.product.new.variante'); |
|
| 58 | 58 | //orders |
| 59 | - Route::get('/admin/ordini',[AdminOrdersController::class,'page'])->name('admin.orders.list'); |
|
| 59 | + Route::get('/admin/ordini', [AdminOrdersController::class, 'page'])->name('admin.orders.list'); |
|
| 60 | 60 | |
| 61 | 61 | |
| 62 | 62 | |
| 63 | 63 | /***************** |
| 64 | 64 | *-----POST------* |
| 65 | 65 | *****************/ |
| 66 | - Route::post('/admin/post/get/categories/tree',[AdminCategoryController::class,'getStructureCategories'])->name('admin.post.get.categories.tree'); |
|
| 67 | - Route::post('/admin/post/get/categories',[AdminCategoryController::class,'getCategories'])->name('admin.post.get.categories'); |
|
| 68 | - Route::post('/admin/post/create-new-category',[AdminCategoryController::class,'setNewCategory'])->name('admin.post.create.new.category'); |
|
| 66 | + Route::post('/admin/post/get/categories/tree', [AdminCategoryController::class, 'getStructureCategories'])->name('admin.post.get.categories.tree'); |
|
| 67 | + Route::post('/admin/post/get/categories', [AdminCategoryController::class, 'getCategories'])->name('admin.post.get.categories'); |
|
| 68 | + Route::post('/admin/post/create-new-category', [AdminCategoryController::class, 'setNewCategory'])->name('admin.post.create.new.category'); |
|
| 69 | 69 | |
| 70 | 70 | //details |
| 71 | - Route::post('/admin/post/create/detail',[AdminDetailController::class,'setNewDetail'])->name('admin.post.create.detail'); |
|
| 72 | - Route::post('/admin/post/get/details',[AdminDetailController::class,'getDetails'])->name('admin.post.get.details'); |
|
| 71 | + Route::post('/admin/post/create/detail', [AdminDetailController::class, 'setNewDetail'])->name('admin.post.create.detail'); |
|
| 72 | + Route::post('/admin/post/get/details', [AdminDetailController::class, 'getDetails'])->name('admin.post.get.details'); |
|
| 73 | 73 | |
| 74 | 74 | //configuration |
| 75 | - Route::post('/admin/post/create/configuration',[AdminConfigurationFieldController::class,'setNewConfiguration'])->name('admin.post.create.configuration'); |
|
| 76 | - Route::post('/admin/post/get/configuration',[AdminConfigurationFieldController::class,'getConfigurationFields'])->name('admin.post.get.configuration'); |
|
| 75 | + Route::post('/admin/post/create/configuration', [AdminConfigurationFieldController::class, 'setNewConfiguration'])->name('admin.post.create.configuration'); |
|
| 76 | + Route::post('/admin/post/get/configuration', [AdminConfigurationFieldController::class, 'getConfigurationFields'])->name('admin.post.get.configuration'); |
|
| 77 | 77 | |
| 78 | 78 | //product |
| 79 | - Route::post('/admin/prodotto/crea-prodotto',[AdminNewProductController::class,'createNewProduct'])->name('admin.post.product.new'); |
|
| 80 | - Route::post('/admin/prodotto/crea-variante-prodotto',[AdminNewProductVariationController::class,'createNewVariation'])->name('admin.post.product.variation.new'); |
|
| 81 | - Route::post('/admin/prodotto/crea-singolo-prodotto',[AdminNewSingleProductController::class,'createNewSingleProduct'])->name('admin.post.new.single.product'); |
|
| 79 | + Route::post('/admin/prodotto/crea-prodotto', [AdminNewProductController::class, 'createNewProduct'])->name('admin.post.product.new'); |
|
| 80 | + Route::post('/admin/prodotto/crea-variante-prodotto', [AdminNewProductVariationController::class, 'createNewVariation'])->name('admin.post.product.variation.new'); |
|
| 81 | + Route::post('/admin/prodotto/crea-singolo-prodotto', [AdminNewSingleProductController::class, 'createNewSingleProduct'])->name('admin.post.new.single.product'); |
|
| 82 | 82 | |
| 83 | 83 | |
| 84 | 84 | //refresh |
| 85 | - Route::get('/admin/update',[AdminUpdatePackageController::class,'update'])->name('admin.updatepackage'); |
|
| 85 | + Route::get('/admin/update', [AdminUpdatePackageController::class, 'update'])->name('admin.updatepackage'); |
|
| 86 | 86 | |
| 87 | 87 | }); |
@@ -8,13 +8,13 @@ |
||
| 8 | 8 | |
| 9 | 9 | class ShopCheckoutController extends Controller |
| 10 | 10 | { |
| 11 | - public function page(){ |
|
| 11 | + public function page() { |
|
| 12 | 12 | $note = session('checkout.note_delivery'); |
| 13 | 13 | $delivery_where = session('checkout.get_in_shop_checkbox'); |
| 14 | - return view('mongicommerce.pages.checkout',compact('note','delivery_where')); |
|
| 14 | + return view('mongicommerce.pages.checkout', compact('note', 'delivery_where')); |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | - public function saveDetailsInSession(Request $r){ |
|
| 17 | + public function saveDetailsInSession(Request $r) { |
|
| 18 | 18 | $note_delivery = $r->get('note_delivery'); |
| 19 | 19 | $get_in_shop_checkbox = $r->get('get_in_shop_checkbox'); |
| 20 | 20 | session()->put('checkout.note_delivery', $note_delivery); |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | class ShopSummaryController extends Controller |
| 12 | 12 | { |
| 13 | - public function page(){ |
|
| 13 | + public function page() { |
|
| 14 | 14 | $products = []; |
| 15 | 15 | $note = session('checkout.note_delivery'); |
| 16 | 16 | $get_in_shop_checkbox = session('checkout.get_in_shop_checkbox'); |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | if (!Auth::check()) { |
| 19 | 19 | $ids = []; |
| 20 | 20 | $productsCart = session('cart'); |
| 21 | - if(isset($productsCart)){ |
|
| 21 | + if (isset($productsCart)) { |
|
| 22 | 22 | foreach ($productsCart as $id => $count) { |
| 23 | 23 | $product = ProductItem::where('id', $id)->first(); |
| 24 | 24 | $ids[] = $id; |
@@ -51,6 +51,6 @@ discard block |
||
| 51 | 51 | } |
| 52 | 52 | $shipping_price = 0; |
| 53 | 53 | session()->put('checkout.total', $total + $shipping_price); |
| 54 | - return view('mongicommerce.pages.summary',compact('products','total','shipping_price','note','get_in_shop_checkbox')); |
|
| 54 | + return view('mongicommerce.pages.summary', compact('products', 'total', 'shipping_price', 'note', 'get_in_shop_checkbox')); |
|
| 55 | 55 | } |
| 56 | 56 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | class ShopCartController extends Controller |
| 12 | 12 | { |
| 13 | - public function page(){ |
|
| 13 | + public function page() { |
|
| 14 | 14 | return view('mongicommerce.pages.cart'); |
| 15 | 15 | } |
| 16 | 16 | /** |
@@ -24,12 +24,12 @@ discard block |
||
| 24 | 24 | $checkElement = Cart::where('product_item_id', $product->id)->first(); |
| 25 | 25 | //if is null it means the cart is empty |
| 26 | 26 | if (is_null($checkElement)) { |
| 27 | - if($num_avaibile_product > 0){ |
|
| 27 | + if ($num_avaibile_product > 0) { |
|
| 28 | 28 | return true; |
| 29 | - }else{ |
|
| 29 | + } else { |
|
| 30 | 30 | return false; |
| 31 | 31 | } |
| 32 | - }else{ |
|
| 32 | + } else { |
|
| 33 | 33 | //if there is something in the cart check the avaibility |
| 34 | 34 | if ($checkElement->quantity + 1 <= $num_avaibile_product) { |
| 35 | 35 | return true; |
@@ -45,28 +45,28 @@ discard block |
||
| 45 | 45 | $product = ProductItem::find($product_item_id); |
| 46 | 46 | $check = $this->checkIfProductAvaible($product); |
| 47 | 47 | |
| 48 | - if($check){ |
|
| 48 | + if ($check) { |
|
| 49 | 49 | //if i'am not authenticated |
| 50 | 50 | if (!Auth::check()) { |
| 51 | 51 | session()->push('products.ids', $product_item_id); |
| 52 | - session()->put('cart',self::getCountableCart(session('products.ids'))); |
|
| 52 | + session()->put('cart', self::getCountableCart(session('products.ids'))); |
|
| 53 | 53 | return response()->json(session('cart')); |
| 54 | - }else{ |
|
| 54 | + } else { |
|
| 55 | 55 | //if number i want is less than number avaible product i can add into cart |
| 56 | - $mycart = Cart::where('product_item_id',$product->id)->where('user_id',Auth::user()->id)->first(); |
|
| 57 | - if(is_null($mycart)){ |
|
| 56 | + $mycart = Cart::where('product_item_id', $product->id)->where('user_id', Auth::user()->id)->first(); |
|
| 57 | + if (is_null($mycart)) { |
|
| 58 | 58 | $cart = new Cart(); |
| 59 | 59 | $cart->user_id = Auth::user()->id; |
| 60 | 60 | $cart->product_item_id = $product_item_id; |
| 61 | 61 | $cart->quantity = 1; |
| 62 | 62 | $cart->save(); |
| 63 | - }else{ |
|
| 63 | + } else { |
|
| 64 | 64 | $mycart->quantity = $mycart->quantity + 1; |
| 65 | 65 | $mycart->save(); |
| 66 | 66 | } |
| 67 | 67 | return true; |
| 68 | 68 | } |
| 69 | - }else{ |
|
| 69 | + } else { |
|
| 70 | 70 | return response()->json([ |
| 71 | 71 | 'errors' => "Prodotto non disponibile o terminato", |
| 72 | 72 | ], 422); |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | $ids = []; |
| 123 | 123 | session()->forget('products.ids'); |
| 124 | 124 | $productsCart = session('cart'); |
| 125 | - if(isset($productsCart)){ |
|
| 125 | + if (isset($productsCart)) { |
|
| 126 | 126 | foreach ($productsCart as $id => $count) { |
| 127 | 127 | $product = ProductItem::where('id', $id)->first(); |
| 128 | 128 | $ids[] = $id; |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | ]; |
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | - session()->put('products.ids',$ids); |
|
| 139 | + session()->put('products.ids', $ids); |
|
| 140 | 140 | |
| 141 | 141 | } else { |
| 142 | 142 | $productsCart = Cart::where('user_id', Auth::user()->id)->get(); |
@@ -153,26 +153,26 @@ discard block |
||
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - return response()->json(['product' => $products , 'total' => self::calculateTotalPrice($products)]); |
|
| 156 | + return response()->json(['product' => $products, 'total' => self::calculateTotalPrice($products)]); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - public function incrementOrDecrementElementInCart(Request $r){ |
|
| 159 | + public function incrementOrDecrementElementInCart(Request $r) { |
|
| 160 | 160 | $product_id = $r->get('product_id'); |
| 161 | 161 | $operator = $r->get('operator'); |
| 162 | 162 | $product = ProductItem::find($product_id); |
| 163 | 163 | if (!Auth::check()) { |
| 164 | 164 | $cart = session('cart'); |
| 165 | 165 | $count_product_in_session = $cart[$product_id]; |
| 166 | - if($product->quantity > $count_product_in_session || $operator < 0){ |
|
| 167 | - if($count_product_in_session > 1 || $operator > 0){ |
|
| 166 | + if ($product->quantity > $count_product_in_session || $operator < 0) { |
|
| 167 | + if ($count_product_in_session > 1 || $operator > 0) { |
|
| 168 | 168 | $cart[$product_id] = $count_product_in_session + $operator; |
| 169 | - session()->put('cart',$cart); |
|
| 169 | + session()->put('cart', $cart); |
|
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | - }else{ |
|
| 173 | - $cart = Cart::where('product_item_id',$product_id)->first(); |
|
| 174 | - if($product->quantity > $cart->quantity || $operator < 0){ |
|
| 175 | - if($cart->quantity > 1 || $operator > 0){ |
|
| 172 | + } else { |
|
| 173 | + $cart = Cart::where('product_item_id', $product_id)->first(); |
|
| 174 | + if ($product->quantity > $cart->quantity || $operator < 0) { |
|
| 175 | + if ($cart->quantity > 1 || $operator > 0) { |
|
| 176 | 176 | $cart->quantity = $cart->quantity + $operator; |
| 177 | 177 | $cart->save(); |
| 178 | 178 | } |
@@ -181,14 +181,14 @@ discard block |
||
| 181 | 181 | |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - public function deleteFromCart(Request $r){ |
|
| 184 | + public function deleteFromCart(Request $r) { |
|
| 185 | 185 | $product_id = $r->get('product_id'); |
| 186 | 186 | if (!Auth::check()) { |
| 187 | 187 | $cart_in_session = session('cart'); |
| 188 | 188 | unset($cart_in_session[$product_id]); |
| 189 | - session()->put('cart',$cart_in_session); |
|
| 190 | - }else{ |
|
| 191 | - Cart::where('product_item_id',$product_id)->delete(); |
|
| 189 | + session()->put('cart', $cart_in_session); |
|
| 190 | + } else { |
|
| 191 | + Cart::where('product_item_id', $product_id)->delete(); |
|
| 192 | 192 | return true; |
| 193 | 193 | } |
| 194 | 194 | } |
@@ -26,10 +26,10 @@ discard block |
||
| 26 | 26 | if (is_null($checkElement)) { |
| 27 | 27 | if($num_avaibile_product > 0){ |
| 28 | 28 | return true; |
| 29 | - }else{ |
|
| 29 | + } else{ |
|
| 30 | 30 | return false; |
| 31 | 31 | } |
| 32 | - }else{ |
|
| 32 | + } else{ |
|
| 33 | 33 | //if there is something in the cart check the avaibility |
| 34 | 34 | if ($checkElement->quantity + 1 <= $num_avaibile_product) { |
| 35 | 35 | return true; |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | session()->push('products.ids', $product_item_id); |
| 52 | 52 | session()->put('cart',self::getCountableCart(session('products.ids'))); |
| 53 | 53 | return response()->json(session('cart')); |
| 54 | - }else{ |
|
| 54 | + } else{ |
|
| 55 | 55 | //if number i want is less than number avaible product i can add into cart |
| 56 | 56 | $mycart = Cart::where('product_item_id',$product->id)->where('user_id',Auth::user()->id)->first(); |
| 57 | 57 | if(is_null($mycart)){ |
@@ -60,13 +60,13 @@ discard block |
||
| 60 | 60 | $cart->product_item_id = $product_item_id; |
| 61 | 61 | $cart->quantity = 1; |
| 62 | 62 | $cart->save(); |
| 63 | - }else{ |
|
| 63 | + } else{ |
|
| 64 | 64 | $mycart->quantity = $mycart->quantity + 1; |
| 65 | 65 | $mycart->save(); |
| 66 | 66 | } |
| 67 | 67 | return true; |
| 68 | 68 | } |
| 69 | - }else{ |
|
| 69 | + } else{ |
|
| 70 | 70 | return response()->json([ |
| 71 | 71 | 'errors' => "Prodotto non disponibile o terminato", |
| 72 | 72 | ], 422); |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | session()->put('cart',$cart); |
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | - }else{ |
|
| 172 | + } else{ |
|
| 173 | 173 | $cart = Cart::where('product_item_id',$product_id)->first(); |
| 174 | 174 | if($product->quantity > $cart->quantity || $operator < 0){ |
| 175 | 175 | if($cart->quantity > 1 || $operator > 0){ |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | $cart_in_session = session('cart'); |
| 188 | 188 | unset($cart_in_session[$product_id]); |
| 189 | 189 | session()->put('cart',$cart_in_session); |
| 190 | - }else{ |
|
| 190 | + } else{ |
|
| 191 | 191 | Cart::where('product_item_id',$product_id)->delete(); |
| 192 | 192 | return true; |
| 193 | 193 | } |
@@ -10,7 +10,7 @@ |
||
| 10 | 10 | |
| 11 | 11 | class ShopShipmentController extends Controller |
| 12 | 12 | { |
| 13 | - public function page(){ |
|
| 13 | + public function page() { |
|
| 14 | 14 | return view('mongicommerce.pages.shipment'); |
| 15 | 15 | } |
| 16 | 16 | } |
@@ -10,7 +10,7 @@ |
||
| 10 | 10 | |
| 11 | 11 | class ShopPaymentController extends Controller |
| 12 | 12 | { |
| 13 | - public function page(){ |
|
| 13 | + public function page() { |
|
| 14 | 14 | return view('mongicommerce.pages.payment'); |
| 15 | 15 | } |
| 16 | 16 | } |