When I do this:
class Content extends Eloquent {
}
Content::saving(function($content) {
// do something
});
class Article extends Content {
}
The 'do something' event doesn't fire when saving an Article. Is there any way that Article can inherit this event binding?
You can use late static binding in the parent's static boot method that laravel automatically calls:
class Content extends Eloquent
{
public static function boot()
{
parent::boot();
static::saving(function ($model) {
// do something
});
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With