Agent47
Agent47

Reputation: 79

Get current user ID in Confide laravel 4

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

Answers (1)

Set Kyar Wa Lar
Set Kyar Wa Lar

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

Related Questions