Search code examples
laravelobserverslaravel-5.8

Why in Laravel 5.8 Observer does not work


Actually made observer by command php artisan make:observer ProfileObserver --model=Profile

In AppServiceProvider.php:-

    public function boot(Request $request) {
        Profile::observe(ProfileObserver::class);       
    }

In ProfileObserver.php:-

    public function updating(Profile $profile) {
        die('here');
    }

and actually i have model Profile Why observer not work ??


Solution

  • I solved it. first i used

    Profile::where('id', $id)->update($inputs);
    

    and that's not triggered any action. Replaced with

    Profile::find($id)->update($inputs);