I have prepared a file .env and sqlite database to make it easy for you to run the project.
- Run the following commands to install and run the project
composer install
2. To fill DB
php artisan db:seed
3. To run the project
php artisan serve
4. To run tests
php artisan test
- GET "/api/products" - get list of products
Parameters:
size (required, integer)
page (required, integer)
Filters:
category (string) - filter by category name of products
discount (integer) - filter by discount percentage of products
priceLess (integer) - filter by product price. This filter applies before discounts are applied and will show products with prices lesser than or equal the value provided
All filter works as a query string parameter.
Example: http://127.0.0.1:8000/api/products/?page=1&size=5&category=boots
You can you multiple filters. It shows a list of products that matches all filters
Example: http://127.0.0.1:8000/api/products/?page=1&size=5&category=boots&priceLess=89000 - GET "api/products/{id}" - get product by id
- POST "api/products" - create new product
Fields:
sku (required, string)
name (required, string)
category (required, string)
price (required, double like 150.00)
discount_id (optional, integer, exists:discounts,id) - PUT "api/products/{id}" - update product
Fields:
sku (string)
name (string)
category (string)
price (double like 150.00)
discount_id (integer, exists:discounts,id) - DELETE "api/products/{id}" - delete product