Action::make('acceptAll')
->before(function ($action, $livewire) {
Log::debug('Before hook');
$groupOrders = $livewire->getTableRecords();
foreach ($groupOrders as $groupOrder) {
if (!$groupOrder->courier) {
Notification::make()
->warning()
->title('Missing Courier')
->body('Group order with route ID ' . $groupOrder->route->id . ' does not have a courier assigned. Please assign a courier and try again.')
->persistent()
->send();
$action->cancel();
return;
}
}
})
->requiresConfirmation()
->action(function ($action, $livewire) use ($orderStatusIds){
// Action logic
}),
Action::make('acceptAll')
->before(function ($action, $livewire) {
Log::debug('Before hook');
$groupOrders = $livewire->getTableRecords();
foreach ($groupOrders as $groupOrder) {
if (!$groupOrder->courier) {
Notification::make()
->warning()
->title('Missing Courier')
->body('Group order with route ID ' . $groupOrder->route->id . ' does not have a courier assigned. Please assign a courier and try again.')
->persistent()
->send();
$action->cancel();
return;
}
}
})
->requiresConfirmation()
->action(function ($action, $livewire) use ($orderStatusIds){
// Action logic
}),