Laravel Observer not triggered on UpdateorCreate

Viewed 398

I have Model Model1 where I want to update a particular column rank on saved.

protected static function boot()
{
    parent::boot();
    static::saved(function ($model) {
         $service = new  Service();
         $service->updateRank($model->id);
    });
}

I put a log inside the saved. but it is not called

1 Answers

You should use method booted.

protected static function booted()
{
    static::saved(function ($model) {
        $service = new  Service();
        $service->updateRank($model->id);
    });
}
Related