- This REST API is for customer management system.
- Laravel Framework 6.20.44
- Laravel Passport 7.5.1
- User registration
- User Login
- Listing Customers
- Create Customer
- View Customer
- Update Customer
- Delete Customer
- Clone the repository
- Composer install
composer install - Set environment
cp .env.example .env - Set the application key
php artisan key:generate - Run migration
php artisan migrate - Run application
php artisan serve
- It requires a machine with Docker installed.
- Update below .env parameters.
DB_HOST, DB_PORT, DB_CONNECTIONexactly as shown below andDB_DATABASE, DB_USERNAME, DB_PASSWORDas your choice.DB_HOST=dbDB_PORT=3306DB_DATABASE=<database_name>DB_USERNAME=<database_user_name>DB_PASSWORD=<database_user_password>DB_CONNECTION=mysql - Update
docker-compose/mysql/init/01-databaes.sqlfile according to the changes made above. - Run container
docker-compose up -d --build - Check the status
docker-compose psyou should see three containers are running. - Bash in to the container to install composer dependencies and run application commands
docker-compose exec app bashcomposer installphp artisan key:generatephp artisan migrate - Application is accessible under http://localhost:8005
| Request | http://127.0.0.1:8000/api/register |
|---|---|
| Method | POST |
| Headers | Accept : application/json |
| Parameters | { "name" : "Demo User", "email" : "[email protected]", "password" : "12345", "c_password" : "12345" } |
| Response | { "success": true, "data": { "token": "xxxxxxxxxxxxxxxxxxx", "name": "Demo User" }, "message": "User register successfully." } |
| Request | http://127.0.0.1:8000/api/login |
|---|---|
| Method | POST |
| Headers | Accept : application/json |
| Parameters | { "email" : "[email protected]", "password" : "12345" } |
| Response | { "success": true, "data": { "token": "xxxxxxxxxxxxxxxxxxx", "name": "Demo User" }, "message": "User register successfully." } |
| Request | http://127.0.0.1:8000/api/customers |
|---|---|
| Method | GET |
| Headers | Accept : application/json |
| Authorization | Bearer Token (Token recieved when login) |
| Parameters | |
| Response | { "success": true, "data": [ { "id": 1, "first_name": "John", "last_name": "Peter", "age": 25, "dob": "1995-05-14", "email": "[email protected]", "created_at": "29/06/2022", "updated_at": "29/06/2022" } ], "message": "Customers retrieved successfully." } |
| Request | http://127.0.0.1:8000/api/customers |
|---|---|
| Method | POST |
| Headers | Accept : application/json |
| Authorization | Bearer Token (Token recieved when login) |
| Parameters | { "first_name" : "John", "last_name" : "Peter", "age" : "25", "dob" : "1995/05/14", "email" : "[email protected]" } |
| Response | { "success": true, "data": { "id": 1, "first_name": "John", "last_name": "Peter", "age": "25", "dob": "1995/05/14", "email": "[email protected]", "created_at": "29/06/2022", "updated_at": "29/06/2022" }, "message": "Customer created successfully." } |
| Request | http://127.0.0.1:8000/api/customers/{customer_id} |
|---|---|
| Method | GET |
| Headers | Accept : application/json |
| Authorization | Bearer Token (Token recieved when login) |
| Parameters | |
| Response | { "success": true, "data": { "id": 1, "first_name": "John", "last_name": "Peter", "age": 25, "dob": "1995-05-14", "email": "[email protected]", "created_at": "29/06/2022", "updated_at": "29/06/2022" }, "message": "Customer retrieved successfully." } |
| Request | http://127.0.0.1:8000/api/customers/{customer_id} |
|---|---|
| Method | PUT |
| Headers | Accept : application/json |
| Authorization | Bearer Token (Token recieved when login) |
| Parameters | { "first_name" : "John", "last_name" : "Peter", "age" : "25", "dob" : "1995/05/14", "email" : "[email protected]" } |
| Response | { "success": true, "data": { "id": 1, "first_name": "John", "last_name": "Peter", "age": "25", "dob": "1995/05/14", "email": "[email protected]", "created_at": "29/06/2022", "updated_at": "29/06/2022" }, "message": "Customer updated successfully." } |
| Request | http://127.0.0.1:8000/api/customers/{customer_id} |
|---|---|
| Method | DELETE |
| Headers | Accept : application/json |
| Authorization | Bearer Token (Token recieved when login) |
| Parameters | |
| Response | { "success": true, "data": [], "message": "Customer deleted successfully." } |