Get the logged in user id

1

How do I get the id of the logged in user and insert it in the table along with description and title? I imagine it to be quite 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');
}
    
asked by anonymous 24.04.2018 / 19:31

1 answer

5

To get the id of the logged in user:

Auth::user()->id

That's if you're using guard that comes by default.

    
24.04.2018 / 19:33