fix(work-order-dashboard): guard getFirstMediaUrl call on Vehicle

Vehicle model doesn't use Spatie MediaLibrary — the direct call broke
the dashboard for any WO whose vehicle has no MediaLibrary integration.
Guard with method_exists and remove the diagnostic logging + URL echo
now that the routing issue is resolved.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-05 20:34:30 +00:00
parent f82a3ebc57
commit 34f53383bf
2 changed files with 4 additions and 12 deletions
@@ -46,16 +46,6 @@ class WorkOrderDashboard extends Page
$id = (int) $wo; $id = (int) $wo;
$this->recordId = $id; $this->recordId = $id;
\Log::warning('WorkOrderDashboard.mount', [
'wo_raw' => $wo,
'wo_int' => $id,
'url' => request()->fullUrl(),
'referer' => request()->headers->get('referer'),
'method' => request()->method(),
'auth_id' => auth()->id(),
'tenant' => app(\App\Tenancy\TenantManager::class)->current()?->slug,
]);
$found = WorkOrder::with([ $found = WorkOrder::with([
'client', 'vehicle', 'master', 'client', 'vehicle', 'master',
'works.labor', 'works.master', 'works.labor', 'works.master',
@@ -71,7 +61,7 @@ class WorkOrderDashboard extends Page
$tenantSlug = $tenant?->slug ?? '—'; $tenantSlug = $tenant?->slug ?? '—';
$msg = $existsGlobally $msg = $existsGlobally
? sprintf(__('Fișa #%d există, dar nu aparține tenantului „%s".'), $id, $tenantSlug) ? sprintf(__('Fișa #%d există, dar nu aparține tenantului „%s".'), $id, $tenantSlug)
: sprintf(__('Fișa #%d nu există. URL apelat: %s'), $id, request()->fullUrl()); : sprintf(__('Fișa #%d nu există.'), $id);
\Filament\Notifications\Notification::make() \Filament\Notifications\Notification::make()
->title(__('Fișă indisponibilă')) ->title(__('Fișă indisponibilă'))
->body($msg) ->body($msg)
@@ -495,7 +495,9 @@
</div> </div>
@if ($wo->vehicle) @if ($wo->vehicle)
@php @php
$photoUrl = $wo->vehicle->getFirstMediaUrl('photos') ?? null; $photoUrl = method_exists($wo->vehicle, 'getFirstMediaUrl')
? ($wo->vehicle->getFirstMediaUrl('photos') ?: null)
: null;
@endphp @endphp
@if ($photoUrl) @if ($photoUrl)
<img class="wd-vehicle-photo" src="{{ $photoUrl }}" alt="{{ $wo->vehicle->make }}"> <img class="wd-vehicle-photo" src="{{ $photoUrl }}" alt="{{ $wo->vehicle->make }}">