为什么在 Laravel 5.8 中 Observer 不起作用

Why in Laravel 5.8 Observer does not work

根据命令实际成为观察者php artisan make:observer ProfileObserver --model=Profile

在AppServiceProvider.php中:-

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

在ProfileObserver.php中:-

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

实际上我有模特个人资料 为什么观察者不起作用??

我解决了。 首先我用

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

并且没有触发任何操作。 替换为

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