protected function mutateFormDataBeforeCreate(array $data): array
{
$data['date_issued'] = date(now());
$amount = $data['stock_issued'];
$stock = DB::table('inventories')->where('id', $data['inventory_id'])->value('stock');
if ($amount > $stock) {
Notification::make()
->warning()
->title('You don\'t have enough Stock!!!')
->body('Only ' . $stock . ' in inventory.')
->send();
$this->halt();
} else {
DB::table('inventories')->where('id', $data['inventory_id'])->update(['stock' => $stock - $amount]);
}
return $data;
}
protected function mutateFormDataBeforeCreate(array $data): array
{
$data['date_issued'] = date(now());
$amount = $data['stock_issued'];
$stock = DB::table('inventories')->where('id', $data['inventory_id'])->value('stock');
if ($amount > $stock) {
Notification::make()
->warning()
->title('You don\'t have enough Stock!!!')
->body('Only ' . $stock . ' in inventory.')
->send();
$this->halt();
} else {
DB::table('inventories')->where('id', $data['inventory_id'])->update(['stock' => $stock - $amount]);
}
return $data;
}