diff --git a/app/Filament/Tenant/Pages/WorkOrderDashboard.php b/app/Filament/Tenant/Pages/WorkOrderDashboard.php index ab66ced..b0cd935 100644 --- a/app/Filament/Tenant/Pages/WorkOrderDashboard.php +++ b/app/Filament/Tenant/Pages/WorkOrderDashboard.php @@ -18,28 +18,37 @@ class WorkOrderDashboard extends Page protected string $view = 'filament.tenant.pages.work-order-dashboard'; + /** + * Livewire persists this across hydration. We use a plain int (NOT + * a typed Model) to avoid triggering route model binding — earlier + * `public ?WorkOrder $record` made Livewire attempt to bind the + * {wo} route param to a WorkOrder, and when that resolution failed + * mount() ended up receiving 0. + */ + public ?int $recordId = null; + public ?WorkOrder $record = null; public string $activeTab = 'works'; public static function getSlug(?\Filament\Panel $panel = null): string { - return 'work-orders/{record}/dashboard'; + return 'work-orders/{wo}/dashboard'; } public static function getRoutePath(?\Filament\Panel $panel = null): string { - return 'work-orders/{record}/dashboard'; + return 'work-orders/{wo}/dashboard'; } - public function mount(int|string $record): void + public function mount(int|string $wo): void { - $id = (int) $record; + $id = (int) $wo; + $this->recordId = $id; - // Log every single mount attempt so we can diagnose the exact request \Log::warning('WorkOrderDashboard.mount', [ - 'record_raw' => $record, - 'record_int' => $id, + 'wo_raw' => $wo, + 'wo_int' => $id, 'url' => request()->fullUrl(), 'referer' => request()->headers->get('referer'), 'method' => request()->method(), @@ -47,7 +56,7 @@ class WorkOrderDashboard extends Page 'tenant' => app(\App\Tenancy\TenantManager::class)->current()?->slug, ]); - $wo = WorkOrder::with([ + $found = WorkOrder::with([ 'client', 'vehicle', 'master', 'works.labor', 'works.master', 'parts.part', @@ -55,7 +64,7 @@ class WorkOrderDashboard extends Page 'subcontractJobs.subcontractor', ])->find($id); - if (! $wo) { + if (! $found) { $existsGlobally = WorkOrder::withoutGlobalScopes() ->where('id', $id)->exists(); $tenant = app(\App\Tenancy\TenantManager::class)->current(); @@ -72,7 +81,7 @@ class WorkOrderDashboard extends Page $this->redirect('/app/work-orders'); return; } - $this->record = $wo; + $this->record = $found; } public function setTab(string $tab): void diff --git a/app/Filament/Tenant/Resources/WorkOrderResource/Pages/EditWorkOrder.php b/app/Filament/Tenant/Resources/WorkOrderResource/Pages/EditWorkOrder.php index c2b7f4e..19b5c78 100644 --- a/app/Filament/Tenant/Resources/WorkOrderResource/Pages/EditWorkOrder.php +++ b/app/Filament/Tenant/Resources/WorkOrderResource/Pages/EditWorkOrder.php @@ -37,7 +37,7 @@ class EditWorkOrder extends EditRecord ->icon('heroicon-m-squares-2x2') ->color('info') ->url(fn () => \App\Filament\Tenant\Pages\WorkOrderDashboard::getUrl( - parameters: ['record' => $this->record->id], + parameters: ['wo' => $this->record->id], panel: 'tenant', )), Actions\Action::make('apply_template')