@extends('layouts.app') @push('styles') @endpush @section('content')
{{-- En-tête --}}

Panier

@if($cart && $cart->items && $cart->items->isNotEmpty() && ($canPayOnline ?? false) && function_exists('checkout_payments_enabled') && checkout_payments_enabled()) Payer @endif
@if(session('success'))
{{ session('success') }}
@endif @if(session('error'))
{{ session('error') }}
@endif @if(!$cart || !$cart->items || $cart->items->isEmpty()) {{-- Panier vide --}}

Votre panier est vide

Parcourez les services et produits pour ajouter des articles.

Découvrir les services
@else {{-- ===== VERSION MOBILE : CARTES ===== --}}
@foreach($cart->items as $item) @php $p = $item->purchasable; $remaining = max(0, (float)($item->line_total ?? 0) - (float)($item->line_deposit ?? 0)); @endphp
{{-- Ligne 1 : Titre + Supprimer --}}
@if($p instanceof \App\Models\Booking) Réservation #{{ $p->booking_number ?? $p->id }} @elseif($p instanceof \App\Models\EquipmentRentalRequest) Location matériel #{{ $p->id }} @elseif($p instanceof \App\Models\UrgentSale) {{ $p->title ?? ('Produit #' . $p->id) }} @else Article #{{ $item->id }} @endif
{{ class_basename($item->purchasable_type ?? 'Article') }}
@csrf @method('DELETE')
{{-- Ligne 2 : Quantité --}}
Quantité @if($p instanceof \App\Models\UrgentSale)
@csrf @method('PATCH') @php $maxStock = max(1, (int)(($p->quantity ?? 1) - ($p->reserved_quantity ?? 0) - ($p->sold_quantity ?? 0))); @endphp
@else {{ $item->quantity }} @endif
{{-- Ligne 3 : Prix --}}
Total {{ number_format((float)($item->line_total ?? 0), 2) }} €
Acompte {{ number_format((float)($item->line_deposit ?? 0), 2) }} €
Reste à payer {{ number_format((float)($remaining ?? 0), 2) }} €
{{-- Bouton réserve --}} @if($p instanceof \App\Models\UrgentSale) @php try { $itemHasOnlinePayment = (function_exists('normalize_payment_requirement_for_mode') ? normalize_payment_requirement_for_mode($p->payment_requirement ?? 'none') : ($p->payment_requirement ?? 'none')) === 'full'; $itemPresta = $p->prestataire ?? null; $itemHasPayMethod = $itemPresta && !empty($itemPresta->stripe_account_id); } catch (\Throwable $ex) { $itemHasOnlinePayment = false; $itemHasPayMethod = false; } @endphp @if(!$itemHasOnlinePayment || !$itemHasPayMethod) @if(\Illuminate\Support\Facades\Route::has('urgent-sales.reserve')) @endif @endif @endif
@endforeach
{{-- ===== VERSION DESKTOP : TABLE ===== --}}
@foreach($cart->items as $item) @php $p = $item->purchasable; @endphp @php $remaining = max(0, (float)($item->line_total ?? 0) - (float)($item->line_deposit ?? 0)); @endphp @endforeach
Article Qté Total Acompte Reste
@if($p instanceof \App\Models\Booking) Réservation #{{ $p->booking_number ?? $p->id }} @elseif($p instanceof \App\Models\EquipmentRentalRequest) Location matériel #{{ $p->id }} @elseif($p instanceof \App\Models\UrgentSale) {{ $p->title ?? ('Produit #' . $p->id) }} @else Article #{{ $item->id }} @endif
{{ class_basename($item->purchasable_type ?? 'Article') }}
@if($p instanceof \App\Models\UrgentSale)
@csrf @method('PATCH') @php $maxStock = max(1, (int)(($p->quantity ?? 1) - ($p->reserved_quantity ?? 0) - ($p->sold_quantity ?? 0))); @endphp
@else {{ $item->quantity }} @endif
{{ number_format((float)($item->line_total ?? 0), 2) }} € {{ number_format((float)($item->line_deposit ?? 0), 2) }} €{{ number_format((float)($remaining ?? 0), 2) }} € @if($p instanceof \App\Models\UrgentSale) @php try { $itemHasOnlinePayment = (function_exists('normalize_payment_requirement_for_mode') ? normalize_payment_requirement_for_mode($p->payment_requirement ?? 'none') : ($p->payment_requirement ?? 'none')) === 'full'; $itemPresta = $p->prestataire ?? null; $itemHasPayMethod = $itemPresta && !empty($itemPresta->stripe_account_id); } catch (\Throwable $ex) { $itemHasOnlinePayment = false; $itemHasPayMethod = false; } @endphp @if(!$itemHasOnlinePayment || !$itemHasPayMethod) @if(\Illuminate\Support\Facades\Route::has('urgent-sales.reserve')) @endif @endif @endif
@csrf @method('DELETE')
{{-- ===== RÉCAPITULATIF (responsive) ===== --}}
Total (paiement complet) {{ number_format((float)($totals['full'] ?? 0), 2) }} €
Total acompte {{ number_format((float)($totals['deposit'] ?? 0), 2) }} €
Reste à payer plus tard {{ number_format(max(0, (float)($totals['full'] ?? 0) - (float)($totals['deposit'] ?? 0)), 2) }} €
@if(($canPayOnline ?? false) && function_exists('checkout_payments_enabled') && checkout_payments_enabled()) Payer maintenant @else
Paiement hors plateforme

Utilisez le bouton "Réserver" sur chaque article pour envoyer une demande au vendeur.

@endif
@endif
{{-- Modal de réservation depuis le panier --}} @if(isset($cart) && $cart && $cart->items && $cart->items->isNotEmpty()) @endif @endsection @push('scripts') @endpush