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.
This commit is contained in:
Valentin Lab
2026-02-13 03:54:40 +01:00
parent f6eb686fcd
commit 552b823b8b

View File

@@ -25,13 +25,21 @@
@foreach ($lastOrders as $order)
<tr>
<td>
<a href="{{ route('Admin.Shop.Customers.edit', ['id' => $order->customer->id]) }}"
class="alert-link green">
{{ $order->customer->first_name }}
{{ $order->customer->last_name }}
</a>
@if ($order->customer)
<a href="{{ route('Admin.Shop.Customers.edit', ['id' => $order->customer->id]) }}"
class="alert-link green">
{{ $order->customer->first_name }}
{{ $order->customer->last_name }}
</a>
@else
<span class="text-muted">Client supprimé</span>
@endif
</td>
<td>
@if ($order->customer)
{{ $order->customer->city }} ({{ substr($order->customer->zipcode, 0, 2) }})
@endif
</td>
<td>{{ $order->customer->city }} ({{ substr($order->customer->zipcode, 0, 2) }})</td>
<td>{{ Carbon\Carbon::parse($order->created_at)->format('d/m/Y H:i') }}</td>
<td class="text-right font-weight-bold">
{{ $order->total_shipped }}