Update fireModelEvent('creating') to follow Laravel behavior and support early return (#40)

* Return early if required

* remove false
This commit is contained in:
MaxGiting
2025-04-24 10:36:41 +05:00
committed by GitHub
parent f68ff42426
commit 3ea6bbc2a7
+4 -1
View File
@@ -149,7 +149,10 @@ class BaseModel
public static function create(array $attributes = [])
{
$model = static::make($attributes);
$model->fireModelEvent('creating', false);
if ($model->fireModelEvent('creating') === false) {
return false;
}
if ($model->save()) {
$model->wasRecentlyCreated = true;