退出登录的问题

AuthenticatesUsers.php 中的getLogout方法代码如下

public function logout()
    {
        var_dump(Auth::user());
        var_dump(Auth::check());exit;
        Auth::guard($this->getGuard())->logout();
        //Auth::logout();
        //var_dump(Auth::logout());exit();
        return redirect(property_exists($this, 'redirectAfterLogout') ? $this->redirectAfterLogout : '/');
    }

执行结果

NULL bool(false)

上面的输出调试看似没问题,但是我在控制输出

public function index()
    {
        dd(\Auth::user());
        $articles = DB::table('articles')->orderby('id', 'desc')->paginate(3);

        return view('articles.index', ['articles' => $articles]);
    }

输出结果

User {#182 ▼
  #fillable: array:3 [▶]
  #hidden: array:2 [▶]
  #connection: null
  #table: null
  #primaryKey: "id"
  #keyType: "int"
  #perPage: 15
  +incrementing: true
  +timestamps: true
  #attributes: array:7 [▶]
  #original: array:7 [▶]
  #relations: []
  #visible: []
  #appends: []
  #guarded: array:1 [▶]
  #dates: []
  #dateFormat: null
  #casts: []
  #touches: []
  #observables: []
  #with: []
  #morphClass: null
  +exists: true
  +wasRecentlyCreated: false
}
  • 2者的输出不一致,这个是什么原因,

JellyBool
修改的评论也不能少于六个字哦!
826186458 回复 JellyBool
修改的评论也不能少于六个字哦!
insertSweat
修改的评论也不能少于六个字哦!