Gaston only reads the weather, and Odette only reads the village fair. Each section will get its own page: /sections/weather, /sections/village-fair, /sections/news-in-brief. The name in the address is the value of the Rubrique (section) enum, the one you gave it in chapter 2.
Your mission
- Add a static method
public static function articlesDe(Rubrique $rubrique): array(articles of) toRedaction, which returns the list of articles in that section. Likepublications(), you call it on the class:Redaction::articlesDe(Rubrique::Meteo). - Declare the route
GET /sections/{nom}(nom: name): find the section withRubrique::from(), then show an<h2 class="titre-rubrique">with its label, and its articles inside<main class="articles">. The browser tab shows “label — The Saint-Glinglin Gazette”. - On every article, the section label (
<p class="rubrique">) becomes a link to the section's page.
Reminder
A backed enum (enum Rubrique: string) can find a case from its value: Rubrique::from('weather') gives Rubrique::Meteo, and ->value goes the other way. With an unknown value, from() throws an error: we'll deal with that in the next exercise.