JeffreyWay / Laravel-Model-Validation

This Laravel package auto-validates a model on save.
https://packagist.org/packages/way/database
275 stars 54 forks source link

Another saving() in the child #36

Closed pdcmoreira closed 9 years ago

pdcmoreira commented 9 years ago

Ok, the Model class uses the saving() method to hook into the saving event, but what if I need to use another saving() event on the child?


class Car extends Model {
    protected static $rules = [];

    public static function boot() {
        parent::boot();
        static::saving(function($model) {
            $model->doStuff(); // <- this doesn't execute
        });
    }
}
pdcmoreira commented 9 years ago

I found out the solution and made a pull request with the fix.