Update fireModelEvent('creating') to follow Laravel behavior and support early return (#40)
* Return early if required * remove false
This commit is contained in:
+4
-1
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user