The adventurers love having the menu on their scroll. Now they want to know what others think of a dish before ordering it (Gimli swears by it).
Your mission
Add GET /api/dishes/{slug}: a dish's page, which repeats the menu details and adds:
avis(reviews): the dish's reviews, newest first. Each review publishesauteur(author),note(rating),messageandcreeLe(created at), the latter in the2026-09-11format;noteMoyenne(average rating): the average of the ratings, rounded to one decimal place, ornullas long as nobody has left a review.
The menu (GET /api/dishes) must stay light: no reviews and no average rating.
{ "slug": "dwarf-stew", "nom": "Grumpy Dwarf Stew", "prix": 12.5, "…": "…", "avis": [ { "auteur": "Legolas", "note": 2, "message": "A bit heavy for an elf.", "creeLe": "2026-09-11" } ], "noteMoyenne": 3.5 }
Finally, an unknown dish must give a 404 in JSON. Try /api/dishes/grilled-unicorn in the preview: it's an HTML page! A scroll wouldn't understand a word of it.
Good to know
- Several groups at once:
context: ['groups' => ['carte', 'plat']]. #[Groups]can also go on a method: a computed value becomes a field of the JSON.#[Context]configures the serialization of a single property, for example the format of a date.- A route's format (
format: 'json') tells Symfony to respond in JSON, errors included, even when the client doesn't ask for anything. Errors then follow the Problem Details format (RFC 9457):type,title,status,detail.