@@ -25,10 +25,10 @@ discard block |
||
| 25 | 25 | if (is_null($checkElement)) { |
| 26 | 26 | if($num_avaibile_product > 0){ |
| 27 | 27 | return true; |
| 28 | - }else{ |
|
| 28 | + } else{ |
|
| 29 | 29 | return false; |
| 30 | 30 | } |
| 31 | - }else{ |
|
| 31 | + } else{ |
|
| 32 | 32 | //if there is something in the cart check the avaibility |
| 33 | 33 | if ($checkElement->quantity + 1 <= $num_avaibile_product) { |
| 34 | 34 | return true; |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | session()->push('products.ids', $product_item_id); |
| 51 | 51 | session()->put('cart',self::getCountableCart(session('products.ids'))); |
| 52 | 52 | return response()->json(session('cart')); |
| 53 | - }else{ |
|
| 53 | + } else{ |
|
| 54 | 54 | //if number i want is less than number avaible product i can add into cart |
| 55 | 55 | $mycart = Cart::where('product_item_id',$product->id)->where('user_id',Auth::user()->id)->first(); |
| 56 | 56 | if(is_null($mycart)){ |
@@ -59,13 +59,13 @@ discard block |
||
| 59 | 59 | $cart->product_item_id = $product_item_id; |
| 60 | 60 | $cart->quantity = 1; |
| 61 | 61 | $cart->save(); |
| 62 | - }else{ |
|
| 62 | + } else{ |
|
| 63 | 63 | $mycart->quantity = $mycart->quantity + 1; |
| 64 | 64 | $mycart->save(); |
| 65 | 65 | } |
| 66 | 66 | return true; |
| 67 | 67 | } |
| 68 | - }else{ |
|
| 68 | + } else{ |
|
| 69 | 69 | return response()->json([ |
| 70 | 70 | 'errors' => "Prodotto non disponibile o terminato", |
| 71 | 71 | ], 422); |