Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ctwx's avatar
Level 1

How to get the ID from the previous route/model

Hello, have 2 models:

  • Quiz
  • Question

When I am in the quiz.show I want to add a new question that belongs to a specific quiz. So assume I am at /quizzes/42 and then I click on an "add question" button, which has the route /questions/create. First I used a GET parameter but I wasn't sure if this is the best option. I switched to another approach where I set a session variable in my QuestionController@show action. But I'm still not very content with the approach.

I need some advice. Is there a best practice for this case? What's the most Laravel-like solution?

Best regards, Ctwx

0 likes
2 replies
ctwx's avatar
Level 1

OH! I remember them! I didn't have any use case for it yet, now I remember. Thank you! :)

Please or to participate in this conversation.