Skip to content
Advertisement

How do I get Id in the URL to display comments with Symfony 5?

I’m coding a blog with Symfony 5 and I have issues getting the Id from the URL to display comments from my Database.

To sum up : – I have a view “/fiche/{id}” wish displays specific game informations. – People can leave a comment below, the comment goes in Database with a foreign Key named “jeu_id” wish is the game where the comment were posted.

  • The goal is to display now all the comments wish were posted on this specific game. I want to display all the comments with foreign key “jeu_id” wish is in the url “/fiche/{id}”.

Here’s the method in my controller :

Here’s the concern variables in entity “Commentaires” :

Here’s the concern variables in entity “Jeux” :

Advertisement

Answer

I think the right way would be something like this:

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement