Couldn't you just pass the user to the controller and do
Auth::user()->id
?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm making a quiz site and each user has many quizzes and each quiz has many questions i Have one form which I fill out the title,intro,image of the quiz and send it to quizcontroller which creates a new quiz row in the quiz table but each quiz needs a user_id and I'm not sure of the 'best' way to get it in order to save it to the DB(SQL)
Assuming you want just the id;
$request->user()->id;
Auth::user()->id;
//or just
Auth::id;
Please or to participate in this conversation.