Overview
The table management system provides complete control over restaurant tables, including status tracking, capacity management, and integration with the reservation system.Table Model
The Table model represents physical tables in the restaurant:app/Models/Table.php
Table Attributes
Display name for the table (e.g., “Table 5”, “Window Booth”)
Unique table number for identification (must be unique)
Type of table (e.g., “booth”, “standard”, “outdoor”, “bar”)
Current table status:
disponible, reservada, or ocupadaNumber of seats/capacity (minimum 1)
Table Relationships
One-to-One with Reservations
A table can have only one active reservation at a time. When assigned, the table status changes to ‘reservada’.
One-to-Many with Orders
Table Status System
Tables can have three distinct statuses:- Disponible
- Reservada
- Ocupada
Available for use
- No active reservation
- Not currently occupied
- Can be assigned to new reservations
- Can be seated immediately
Table Controller
The TableController handles all table management operations.List All Tables
app/Http/Controllers/Admin/TableController.php
Create New Table
app/Http/Controllers/Admin/TableController.php
Unique Constraint: The
number field must be unique across all tables. Attempting to create a table with a duplicate number will fail validation.Update Table
app/Http/Controllers/Admin/TableController.php
Unique Validation on Update
Unique Validation on Update
The validation rule
unique:tables,number,' . $table->id ensures the table number is unique except for the current table being updated. This allows keeping the same number during updates.Delete Table
app/Http/Controllers/Admin/TableController.php
Mark Table as Used
Special endpoint to mark reserved tables as available after guest departure:app/Http/Controllers/Admin/TableController.php
Reservation Cleanup
Reservation Cleanup
When marking a table as used, the system:
- Verifies the table is in ‘reservada’ status
- Deletes the associated reservation record
- Changes status back to ‘disponible’
- Makes the table available for new reservations
Update Table Status from HomeController
The HomeController provides an additional method for status updates:app/Http/Controllers/HomeController.php
The validation rule
in:disponible,reservada,ocupada ensures only valid status values can be set.Routes and Access Control
Table management routes are restricted to admin and mesero roles:routes/web.php
- ✅ Admin: Full CRUD access
- ✅ Mesero: Full CRUD access
- ❌ Chef: No access
- ❌ Customers: No access
Status Workflow
Typical table lifecycle:Status Transitions
Status Transitions
Disponible → Reservada
- Triggered when reservation is assigned
- Sets
table_idon Reservation model
- Manual update when guests arrive
- Table still linked to reservation
- Manual update after service complete
- Table ready for next use
- Via
markAsUsed()endpoint - Deletes reservation record
Validation Rules
Required, max 255 characters
Required, must be unique across all tables
Required, max 50 characters (e.g., “booth”, “standard”)
Required, minimum value of 1
Required, must be one of:
disponible, reservada, ocupadaCommon Queries
API Endpoints
Mark as Used API
Mark as Used API
Endpoint: Error Response:
POST /admin/tables/{table}/mark-as-usedSuccess Response:Best Practices
- Unique Numbers: Always use unique table numbers for clear identification
- Status Validation: Only allow valid status transitions
- Reservation Cleanup: Delete reservations when marking tables as used
- Capacity Matching: Match table seats to reservation guest count
- Ordering: Display tables ordered by number for easy navigation
- Type Consistency: Use consistent type values (booth, standard, etc.)
- Pagination: Paginate table lists for large restaurants
Integration with Reservations
When a reservation is assigned to a table:The system enforces that
reservation->guest must equal table->seats for assignment to succeed.Future Enhancements
Consider implementing:- Table sections: Group tables by area (patio, main dining, bar)
- Auto-release: Automatically free tables after reservation time expires
- Occupancy tracking: Track time guests spend at tables
- Table combinations: Allow combining multiple tables for large parties
- Priority seating: VIP or priority customer table assignments