Get the login user id

Asked

Viewed 622 times

1

How do I get the logged-in user id and insert it into the table along with Description and title? I imagine it’s pretty simple.

public function saveCallRegister()
{
     $title = Request()->input('title');
     $description = Request()->input('description');

     DB::insert('INSERT INTO feeds (title, description) VALUES (?, ?)', array($description, $title));

     return redirect()->action('HomeController@index');
}

1 answer

5


To catch the id of the logged-in user:

Auth::user()->id

This if you are using the guard which comes by default.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.