我想广播Illuminate/AuthEvents/Logout。能否覆盖或扩展这个核心事件以包含BroadcastOn方法?
你不能覆盖核心的logout事件。关于这个问题有两种方法。无论哪种方法,你都必须启动你的自定义事件。
loggedOut()
方法中 AuthenticatesUsers
:您必须创建您的自定义事件并覆盖 loggedOut()
方法中 AuthenticatesUsers
来手动启动它,就像这样。
protected function loggedOut(Request $request)
{
event(new CustomLogoutEvent());
}
这将会触发核心事件和你的自定义事件。
SessionGuard
覆盖 logout()
冗长,不建议)。logout()
在 SessionGuard
是触发核心登出事件的地方。覆盖它,只触发您的自定义事件。这样一来,只有一个注销事件被触发。
下面是如何覆盖守护的方法。https:/laravel.comdocs7.xauthentication#adding-custom-guards(添加自定义警卫)