Laravel Auth :: user()获取属性

时间:2017-10-19 14:01:52

标签: authentication laravel-5

当我dump( Auth::user());向我展示时

User {#220 ▼

  #attributes: array:10 [▼
    "id" => "8"
    "name" => "Vitaliy"
    "email" => "dsadsa@i.ua"
    "password" => "=)"
    "remember_token" => null
    "created_at" => "2017-10-19 13:11:21"
    "updated_at" => "2017-10-19 13:11:21"
    "phone" => "412412412"
    "city" => "Dnipro"
    "district" => "Leneinskiy"
  ]
  #original: array:10 [▶]
 ....
}

在受保护的属性中,我们看到了用户表中的信息 我怎样才能获得#attributes? 或者请告诉我如何获取有关已登录用户的所有信息。

2 个答案:

答案 0 :(得分:2)

Auth::user()->name

Auth::user()->email

等...

答案 1 :(得分:1)

Auth::User()->getAttributes();

这将获得登录用户的所有属性。