请问一下上一教程中 Auth::id () 到这里为何不需要修改,依旧能使用?
上一节中通知用户我们用的是,
public function notify($instance)
{
// 如果要通知的人是当前用户,就不必通知了!
if ($this->id == Auth::id()) {
return;
}
$this->increment('notification_count');
$this->laravelNotify($instance);
}
这一节用api构建,不是应该通过Auth::guard('api')->id(),获取登录用户ID吗?
但是我试了,用Auth:id()也可以避免通知自己。
但是在transformer转换其中,我又必须用Auth::guard('api')才能获取到用户实例。
推荐文章: