I need some advice and help on the following topic.
I have a setup of migrations like this.
+--------------------+----------------------+--------------------+
| plates | plates_container | container_slots |
+--------------------+----------------------+--------------------+
| id | id | id |
| plate_container_id | number_of_slots(int) | slot |
| container_slot_id | | occupied (boolean) |
| | | plate_container_id |
+--------------------+----------------------+--------------------+
The relations between tables goes like this.
Plate
- Plate
belongsToaplatecontainer - Plate
belongsTocontainerslot
PlateContainer
- platecontainer
hasManycontainerSlots - platecontainer
hasManyplates
ContainerSlot
- ContainerSlot
belongsToplateContainer - ContainerSlot
hasOneplate
Question
How can I (specified by id) fetch all the number_of_slots and check which of those slots are already occupied and which are not.
So to clarify a bit more. A list like this or similar is what I am asking for.
slots = [
1 => false,
2 => false,
3 => true,
4 => false
//etc
];
If you have any other suggestions regarding the database structure, please let me know in the comments. I am slightly doubtful about updating the occupied attribute every time after the user chooses a slot for the plate.
id)…”, whichidin particular?