Mutate Before Create Function

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.
Solution:
What's not working? Can you be more specific? You have return on second line so everything later won't be executed
Jump to solution
2 Replies
Solution
krekas
krekas12mo ago
What's not working? Can you be more specific? You have return on second line so everything later won't be executed
The Huntsman
The HuntsmanOP12mo ago
well I'm dumb, sorry for wasting your time. it works, Thanks
Want results from more Discord servers?
Add your server