You can create table 'seats' with (idbus, numoftheseat, available (true or false), like this you can get all available (or not) seats for each bus easy.. and number of this of course ( ->count() ).
Are you trying to establish how many seats are unreserved on a trip, or exactly which seats are unreserved on a trip?
Not to sound critical, but your tables have strange names - naming can contribute a lot to simplifying the thought process. Why not have tables like:
• Busses (with columns like capacity, license_number, etc.)
• Trips (columns like departure_time, arrival_time, destination, etc.) - each Bus has many Trips
• Seats (columns like seat_number, passenger_name) - each Trip has many Seats
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community