fix(edit-wo): fall back to URL segment for dashboard link
Under some Livewire lifecycles \$this->record isn't hydrated when
getHeaderActions() runs, so \$this->record->id was null and the URL
came out as /app/work-orders//dashboard. Fall back to the URL segment
(always present because we're at /app/work-orders/{id}/edit) and log
which path was taken to help diagnose.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -31,7 +31,18 @@ class EditWorkOrder extends EditRecord
|
|||||||
|
|
||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
$dashboardUrl = url('/app/work-orders/' . $this->record->id . '/dashboard');
|
// Compute WO id defensively — under some Livewire lifecycles $this->record
|
||||||
|
// may not yet be hydrated when getHeaderActions() runs. Fall back to URL
|
||||||
|
// segment which is always present because we're on /app/work-orders/{id}/edit.
|
||||||
|
$woId = $this->record?->id
|
||||||
|
?? (int) (request()->route('record') ?? request()->segment(3));
|
||||||
|
\Log::info('EditWorkOrder.getHeaderActions', [
|
||||||
|
'record_id_from_prop' => $this->record?->id,
|
||||||
|
'record_id_resolved' => $woId,
|
||||||
|
'route_record' => request()->route('record'),
|
||||||
|
'segment3' => request()->segment(3),
|
||||||
|
]);
|
||||||
|
$dashboardUrl = url('/app/work-orders/' . $woId . '/dashboard');
|
||||||
|
|
||||||
return [
|
return [
|
||||||
Actions\Action::make('dashboard')
|
Actions\Action::make('dashboard')
|
||||||
|
|||||||
Reference in New Issue
Block a user