Laravel 5.8 调用未定义的方法 Illuminate\Events\Dispatcher::fire()

Laravel 5.8 Call to undefined method Illuminate\Events\Dispatcher::fire()

我在用户注册时遇到此错误。我已经搜索了很多这个问题,但仍然无法解决我这边的问题。在laravel 5.8升级中,写着函数fire()改为dispatch(),但是我在我的应用程序的任何文件中都找不到任何fire()函数,所以我可以看到发生了什么。

非常感谢任何帮助。谢谢。

发件人: https://laravel.com/docs/5.8/events#dispatching-events

而不是:

Event::fire(new \App\Events\NewUserSignup($new_user));

改为:

event(new \App\Events\NewUserSignup($new_user));

Illuminate\Events\Dispatcher class 的 fire 方法(在 Laravel 5.4 中被弃用)已被删除(https://github.com/laravel/framework/pull/26392)。您应该改用 dispatch 方法。

而不是: Event::dispatch('customer.created', $customer);

这样做: Event::dispatch('customer.created', $customer);

或: event('customer.created', $customer);