Bruna has an idea for the winter evenings: story nights. A storyteller, a date, a number of seats, and travelers who sign up. Gorm has written the specifications. Your job is to build the feature, end to end, over the six exercises of this chapter.
This chapter is the final project. The instructions say what to do, no longer how: you have learned it all. The hints are there if you need them, and so is the documentation.
The specifications
A story night (App\Entity\Soiree, soirée = evening):
| Field | Type | Rule (message) |
|---|---|---|
titre (title) |
text, 100 characters | required (“Give the story night a title.”) |
conteur (storyteller) |
text, 60 characters | required (“Who is telling the story?”) |
debut (start) |
date and time (DateTimeImmutable) |
in the future (“A story night must be scheduled in the future.”) |
places (seats) |
integer | at least 1 (“There must be at least one seat.”) |
inscriptions (sign-ups) |
its sign-ups, in order of arrival |
It can tell how many seats it has left (getPlacesRestantes()) and whether it is full (isComplete()). Each sign-up counts for its own guests.
A sign-up (App\Entity\Inscription):
| Field | Type | Rule (message) |
|---|---|---|
nom (name) |
text, 60 characters | required (“Enter your name.”) |
email |
text, 180 characters | a valid address (“Enter a valid email address.”) |
personnes (guests) |
integer | from 1 to 6 (“From 1 to 6 guests per sign-up.”) |
soiree |
the story night (required) | |
creeLe (created at) |
date and time, set on creation |
The same address signs up only once for a story night (“You are already signed up for this story night.”), but can sign up for others.
Each property has its usual accessors (getTitre(), setTitre()…), and Soiree::addInscription() attaches the sign-up to the story night.
Your mission
- Write the two entities and their repositories.
- Generate the migration, read it, run it.
You can create the files with the console (make:entity, doctrine:migrations:diff) or with the file explorer's + button.