protected function BeforeCreate()
{
$user = Auth::user();
// Retrieve the user's credit status from the database
$credits = $user->credits;
if ($credits >= 2) {
return true; // Continue with the record creation
} else {
// Insufficient credit, prevent record creation and throw an error notification
Notification::make()
->title('Insufficient Credit')
->error()
->send();
// Return false to prevent record creation
return false;
}
}
protected function BeforeCreate()
{
$user = Auth::user();
// Retrieve the user's credit status from the database
$credits = $user->credits;
if ($credits >= 2) {
return true; // Continue with the record creation
} else {
// Insufficient credit, prevent record creation and throw an error notification
Notification::make()
->title('Insufficient Credit')
->error()
->send();
// Return false to prevent record creation
return false;
}
}