API software for M2 Digital.
The following technologies are being used to make this project work.
- Laravel 9.x - One of the most popular PHP Frameworks.
- MySQL (or MariaDB) - MySQL is an open-source relational database management system. Its name is a combination of "My", the name of co-founder Michael Widenius's daughter, and "SQL", the abbreviation for Structured Query Language.
The features are:
- City (CRUD)
- City group (CRUD)
- Campaigns (CRUD)
- Products (CRUD)
- Discounts (CRUD)
This project is basically a Laravel project. To run it you just need to follow the requirements of the framework. Is strongly recommended to run this project using Docker. You can install Docker following the instructions on the link get Docker.
The next sessions you'll give you some instructions on how to setup this application to run in a Docker container.
The sections below describe how to set up the development environment.
To startup the application you can run the command shown below.
docker-compose up --build -d
Docker command to access the php service:
docker-compose exec php /bin/bash
It will start the applicaiton using some docker containers (nginx, mysql and PHP).
Copy .env.example
to .env
and put your config variables like explained on Laravel Config.
NOTE: The default credentials for database are:
- host: mysql
- database: m2belchior
- user: root
- password: m2belchior
composer install
php artisan key:generate
Enter in the php service and run migration as in a common Laravel project.
php artisan migrate # run migrations
php artisan db:seed # run seeders
Enter in the php service and run command above:
php artisan test # run feature tests
To stop the application you can execute the following command
docker-compose down -v
For get city:
Method: GET
URL: /api/city/all
For input new city:
Method: POST
URL: /api/city/insert
Data body:
- 'name' => 'required | min:3',
- 'group_id' => 'nullable | numeric'
For update city:
- NOTE: At least 1 of the fields below must be completed
Method: POST
URL: /api/city/update/ID_CITY
Data body:
- 'name' => 'nullable | min:3',
- 'group_id' => 'nullable | numeric'
For delete city:
Method: GET
URL: /api/city/delete/ID_CITY
For get city group:
Method: GET
URL: /api/groups/all
For input new city group:
Method: POST
URL: /api/groups/insert
Data body:
- 'name' => 'required | min:3',
- 'campaign_id' => 'nullable | numeric'
For update city group:
- NOTE: At least 1 of the fields below must be completed
Method: POST
URL: /api/groups/update/ID_GROUP
Data body:
- 'name' => 'nullable | min:3',
- 'campaign_id' => 'nullable | numeric'
For delete city group:
Method: GET
URL: /api/groups/delete/ID_GROUP
For get campaign:
Method: GET
URL: /api/campaigns/all
For input new campaign:
- NOTE: status 1 for active and 2 for inactive, default by 1
Method: POST
URL: /api/campaigns/insert
Data body:
- 'name' => 'required | min:3',
- 'status' => 'nullable | numeric'
For update campaign:
- NOTE: At least 1 of the fields below must be completed
Method: POST
URL: /api/campaigns/update/ID_CAMPAIGN
Data body:
- 'name' => 'nullable | min:3',
- 'status' => 'nullable | numeric'
For delete campaign:
Method: GET
URL: /api/campaigns/delete/ID_CAMPAIGN
For get product:
Method: GET
URL: /api/product/all
For input new product:
- NOTE: Price used USD format (0.00)
Method: POST
URL: /api/product/insert
Data body:
- 'name' => 'required | min:3',
- 'price' => 'required | numeric'
For update product:
- NOTE: At least 1 of the fields below must be completed
Method: POST
URL: /api/product/update/ID_PRODUCT
Data body:
- 'name' => 'nullable | min:3',
- 'price' => 'nullable | numeric'
For delete product:
Method: GET
URL: /api/product/delete/ID_PRODUCT
For get discount:
Method: GET
URL: /api/discounts/all
For input new discount:
- NOTE: Discount used USD format (0.00)
Method: POST
URL: /api/discounts/insert
Data body:
- 'campaign_id' => 'required | numeric'
- 'product_id' => 'required | numeric'
- 'discount' => 'required | numeric'
For update discount:
- NOTE: At least 1 of the fields below must be completed
Method: POST
URL: /api/discounts/update/ID_DISCOUNT
Data body:
- 'campaign_id' => 'nullable | numeric'
- 'product_id' => 'nullable | numeric'
- 'discount' => 'nullable | numeric'
For delete discount:
Method: GET
URL: /api/discounts/delete/ID_DISCOUNT