From 552b823b8bbce19232bdb0f7b21cbeaaebb5ea44 Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Fri, 13 Feb 2026 03:54:40 +0100 Subject: [PATCH] fix: prevent error 500 on admin dashboard when order has no customer The ``latestOrders`` partial accessed ``$order->customer->id`` without checking for null. Orders whose customer has been deleted caused the admin dashboard to crash on load. --- .../_partials/latestOrders.blade.php | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/resources/views/Admin/Shop/Dashboard/_partials/latestOrders.blade.php b/resources/views/Admin/Shop/Dashboard/_partials/latestOrders.blade.php index 34b0d7f4..98460c00 100644 --- a/resources/views/Admin/Shop/Dashboard/_partials/latestOrders.blade.php +++ b/resources/views/Admin/Shop/Dashboard/_partials/latestOrders.blade.php @@ -25,13 +25,21 @@ @foreach ($lastOrders as $order) - - {{ $order->customer->first_name }} - {{ $order->customer->last_name }} - + @if ($order->customer) + + {{ $order->customer->first_name }} + {{ $order->customer->last_name }} + + @else + Client supprimé + @endif + + + @if ($order->customer) + {{ $order->customer->city }} ({{ substr($order->customer->zipcode, 0, 2) }}) + @endif - {{ $order->customer->city }} ({{ substr($order->customer->zipcode, 0, 2) }}) {{ Carbon\Carbon::parse($order->created_at)->format('d/m/Y H:i') }} {{ $order->total_shipped }} €