I use the above code to update the inventory when inventory is issued out, I was wondering if there is a function like this but for the delete button so I can undo the inventory update if a record from issued inventory is deleted.
protected function mutateFormDataBeforeCreate(array $data): array
{
$data['date_issued'] = date(now());
return $data;
$amount = $data['stock_issued'];
$stock = 10;
if ($amount > $stock) {
Notification::make()
->warning()
->title('You don\'t have enough Stock!!!')
->body('Only ' . $stock . ' in inventory.')
->send();
$this->halt();
}
}
protected function mutateFormDataBeforeCreate(array $data): array
{
$data['date_issued'] = date(now());
return $data;
$amount = $data['stock_issued'];
$stock = 10;
if ($amount > $stock) {
Notification::make()
->warning()
->title('You don\'t have enough Stock!!!')
->body('Only ' . $stock . ' in inventory.')
->send();
$this->halt();
}
}
Can anyone please tell me what's wrong here, I don't get any errors but it doesn't work, and I tried to use the beforeCreate() Function but that doesn't let me pass the $data array.