Add Order Items
The security and performance of the app should not come in the way of code readability and maintainability.
We'll cover the following
Items management
We will provide three different API endpoints to the user for order items management. The routes/api.php
file can be updated as follows.
<?php
// ...
Route::prefix('order-items')->group(function () {
Route::post('/add/{orderId}', [OrderItemController::class, 'add']);
Route::post('/change-quantity/{orderId}', [OrderItemController::class, 'changeQuantity']);
Route::post('/remove/{orderId}', [OrderItemController::class, 'remove']);
});
// ...
- First, we will let users add multiple order items by passing an array of menu item IDs and quantities.
- The customer may request changes in the quantity of one or more menu items. The second API endpoint will serve for that.
- Some of the order items may be canceled.
Adding new order items
The logic for each of the endpoints is a little advanced, so we will go one by one. Note that we are updating multiple files below.
Get hands-on with 1400+ tech skills courses.