@@ -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 | } |