Reputation: 79
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();
Upvotes: 0
Views: 3634
Reputation: 4634
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.
Upvotes: 2