Tables\Actions\Action::make('group_order')
->url(function (UserOrder $record): ?string {
// Use the already eager-loaded groupOrder if it's available
$groupOrder = $record->groupOrder()->withTrashed()->first();
// Check if the groupOrder exists and is not trashed
if (!$groupOrder || $groupOrder->trashed()) {
// Show a notification to the user
Notification::make()
->warning()
->title('Group Order Not Available')
->body("The group order for the user order by {$record->detail->full_name} with deadline: {$record->deadline} and id: {$record->id} is no longer available.")
->persistent()
->send();
return null; // Halt the action by not returning a URL
}
return GroupOrderResource::getUrl('edit', ['record' => $groupOrder]);
}),
Tables\Actions\Action::make('group_order')
->url(function (UserOrder $record): ?string {
// Use the already eager-loaded groupOrder if it's available
$groupOrder = $record->groupOrder()->withTrashed()->first();
// Check if the groupOrder exists and is not trashed
if (!$groupOrder || $groupOrder->trashed()) {
// Show a notification to the user
Notification::make()
->warning()
->title('Group Order Not Available')
->body("The group order for the user order by {$record->detail->full_name} with deadline: {$record->deadline} and id: {$record->id} is no longer available.")
->persistent()
->send();
return null; // Halt the action by not returning a URL
}
return GroupOrderResource::getUrl('edit', ['record' => $groupOrder]);
}),