To install with Docker using Laravel Sail, follow these steps:
-
Clone the repository:
git clone https://github.com/BadrAbed/foodics.git cd foodics
-
Start the Docker containers :
docker-compose up --build
-
Copy the
.env.example
file to.env
:cp .env.example .env
-
install composer :
composer install
-
Generate an application key:
php artisan key:generate
-
Run the database migrations and seed the database:
php artisan db:seed
-
Start the queue worker to process email notifications:
php artisan queue:work
The main components of the application are:
app/Http/Controllers/Api/V1/OrderController
- The controller responsible for handling order creation requestsapp/Http/Controllers/Api/ApiBaseController
- base class for apis to handle responseapp/Http/Requests/StoreOrderRequest
- The request validation class for validating the order creation requestapp/Mail/LowIngredientStock
- The email notification sent to the ingredient merchant when an ingredient falls below a certain thresholdapp/Services/OrderService
- The service class that encapsulates the business logic for creating an orderdatabase
- The directory that contains the database migration, factory, and seeder filesroutes/api
- API routestests/Features/OrderTest
- The feature test class that tests the common scenarios for creating an order
POST /api/orders
Request body example:
{
"products": [
{
"product_id": 1,
"quantity": 2
}
]
}
To run the feature tests, run the following command:
php artisan test