Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Auth::user() get attributes

when i dump( Auth::user()); that show me

User {#220 ▼

  #attributes: array:10 [▼
    "id" => "8"
    "name" => "Vitaliy"
    "email" => "[email protected]"
    "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 [▶]
 ....
}

In protected property we saw the info from user table How can i get #attributes? Or say me please how i can take all info about logged User.

like image 656
Vitaliy Eremenko Avatar asked Dec 19 '22 03:12

Vitaliy Eremenko


2 Answers

Auth::user()->name

Auth::user()->email

etc...

like image 91
Joe Avatar answered Dec 20 '22 17:12

Joe


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

This will get all the attributes of the logged in user.

like image 42
R T Avatar answered Dec 20 '22 15:12

R T