Transitioning Table States
Discover one more way to keep your controllers lean while adding the code for state transitions.
We'll cover the following
New API endpoints
Now that we have set up the table state rules, we can add new API endpoints that will allow users to change the state of a table.
<?php
// ...
Route::post('/mark-as-non-operational/{tableId}', [TableStatusController::class, 'markAsNonOperational']);
Route::post('/mark-as-available/{tableId}', [TableStatusController::class, 'markAsAvailable']);
Route::post('/mark-as-reserved/{tableId}', [TableStatusController::class, 'markAsReserved']);
// ...
Marking the table as occupied will happen automatically when a table is booked. For other states, we can keep these simple API endpoints.
Transition it
Just like previous controllers, we try to keep our new controller slim and trim.
Get hands-on with 1200+ tech skills courses.