fix(edit-wo): build dashboard URL eagerly, outside action closure

The action ->url() closure was resolving \$this to the Action instance
and its ->getRecord() returned null in header-action context, so the URL
came out as /app/work-orders//dashboard.

getHeaderActions() runs after mount(), so \$this->record is guaranteed
populated. Compute the URL string once and pass it as a plain value.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-05 19:52:23 +00:00
parent 67a87c5a67
commit 5301c98621
@@ -31,12 +31,14 @@ class EditWorkOrder extends EditRecord
protected function getHeaderActions(): array protected function getHeaderActions(): array
{ {
$dashboardUrl = url('/app/work-orders/' . $this->record->id . '/dashboard');
return [ return [
Actions\Action::make('dashboard') Actions\Action::make('dashboard')
->label(__('Vizualizare dashboard')) ->label(__('Vizualizare dashboard'))
->icon('heroicon-m-squares-2x2') ->icon('heroicon-m-squares-2x2')
->color('info') ->color('info')
->url(fn ($livewire) => url('/app/work-orders/' . ($livewire->record?->id ?? $livewire->getRecord()?->id) . '/dashboard')), ->url($dashboardUrl),
Actions\Action::make('apply_template') Actions\Action::make('apply_template')
->label(__('Aplică șablon')) ->label(__('Aplică șablon'))
->icon('heroicon-m-clipboard-document-list') ->icon('heroicon-m-clipboard-document-list')