关于 Laravel 的事件 Event 的的一个简单的问题

我按照教程学习laravel的事件,但是老是报这个错误Call to undefined method Illuminate\Events\Dispatcher::fire()
我在EventServiceProvider 里面想添加一个事件,
protected $listen = [
'App\Events\NewBlogView' => [
'App\Listeners\NewBlogViewListener',
],
]
然后在NewBlogView.php文件中,用了一个模型获取用户,
public $users;
public function __construct(User $user)
{
$this->users=$user;
}

然后在NewBlogViewListener.php中,handle方法
public function handle(NewBlogView $event)
{
$id = $event->users->id;
return $id.'news';
}
添加一条路由,
Route::get('/event/{id}','BlogController@showPost');
在控制器中 BlogController.php ,
use Event;
public function showPost($id)
{
$user = User::find($id);
Event::fire(new NewBlogView($user));
}
我都是按照教程写的,但是就老是报错,帮忙看看哪里出了问题,这Event门面有没有这个fire方法的?

《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
讨论数量: 4

当我用event(new NewBlogView($user)); 运行不报错,用大写的Event时候就报错

5年前 评论

大写的是 这样写 \EVENT

5年前 评论

Event::dispatch(new OrderEvent($article_result));

5年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!