How to get the current logged-in user's details in Laravel 4? My code is:
$user = User::find(Confide::user()->id);
$message = new Message(Input::all());
$message->user_id = $user;
$message->save();
How to get the current logged-in user's details in Laravel 4? My code is:
$user = User::find(Confide::user()->id);
$message = new Message(Input::all());
$message->user_id = $user;
$message->save();
收起
If you are using Laravel default Authentication so you can simply call like the following
$id = Auth::id();
Laravel documentation explain like the following
To retrieve the authenticated user's ID, you may use the
id
method:$id = Auth::id();
Read more about Authentication at Laravel's Documentation.
报告相同问题?