Fixed : Negative basket threw a 500 error

This commit is contained in:
Noah Lancien 2023-08-16 16:35:47 +02:00
parent d47e2f45f5
commit a4a41422ba
2 changed files with 11 additions and 2 deletions

View file

@ -71,10 +71,14 @@ class OrderTunnelController extends Controller
Cart::instance('panier');
$cart = Cart::content();
// Check that we have products in cart before saving.
if (count($cart) == 0) {
if (Cart::count() <= 0) {
// Then redirect to empty recap.
return redirect()->route('sales.recap');
return redirect()->route('sales.recap')->with(
'message',
'Le nombre total de produits dans cette commande ne peut être négatif.'
);
}
// Save.

View file

@ -8,6 +8,11 @@
@section('content')
<main id="command" class="container">
<div class="row m-0">
@if (\Session::has('message'))
<div class="w-100 text-red text-center">
{!! \Session::get('message') !!}
</div>
@endif
@include('partials.tunnel-stepper')
<article class="col mt-6 m-lg-0">
<p class="d-none d-lg-block title-regular text-center text-lg-end text-uppercase font-Barlow-extra-bold m-3">Récapitulatif de votre panier</p>