Bank Support Ticket API
- Clone the Repository: Open your terminal (command prompt) and navigate to the directory where you want to store the project. Run the following command to clone the repository:
git clone https://github.com/imabulhasan99/bank-ticket.git
- Install Dependencies: Navigate into the project directory and install Composer dependencies:
cd bank-ticket
composer install
- Set Up Environment: Create a copy of the
.env.example
file and rename it to.env
. Update the database connection settings in the.env
file to match your local environment.
cp .env.example .env
- Generate Application Key: Generate a new application key for your Laravel project:
php artisan key:generate
- Run Migrations and Seeders: Run database migrations and seeders to create database tables and seed initial data:
php artisan migrate --seed
- Serve the Application: Start the Laravel development server to serve your application locally:
php artisan serve
After database seeding it will create a demo branch called Branch 1. Later you can delete it
Now, your Laravel project should be running locally, and you can access it in your web browser.
- Authentication Endpoints:
- [POST] /user/register
- [POST] /manager/register
- [POST] /itdesk/register
- [POST] /login
- [POST] /logout
- Branch Endpoints:
- [POST] /branch/create
- [GET] /branch/list
- [POST] /branch/update/{id}
- [POST] /branch/delete/{id}
- User Endpoints:
- [GET] /user/list
- Category Endpoints:
- [POST] /category/create
- [GET] /category/list
- [POST] /category/update/{id}
- [POST] /category/delete/{id}
- Subcategory Endpoints:
- [POST] /subcategory/create
- [POST] /subcategory/update/{id}
- [POST] /subcategory/delete/{id}
- Ticket Endpoints:
- [POST] /ticket/create
- [GET] /ticket/list
- [POST] /ticket/update/{id}
- [POST] /ticket/delete/{id}
Method: POST
Description:
- This endpoint is used to register a new user, manager, or IT desk user.
Request Body Parameters:
- name: (Required) The name of the user. It must be a string with a maximum length of 255 characters.
- email: (Required) The email address of the user. It must be a valid email format and unique in the users table, with a maximum length of 255 characters.
- password: (Required) The password of the user. It must be a string with a minimum length of 3 characters.
- branch_id: (optional) The ID of the branch the user belongs to. It must be an integer with a minimum value of 1.
- mobile: (Optional) The mobile number of the user. It must be an integer.
{ "name": "John Doe", "email": "[email protected]", "password": "secretpassword", "branch_id": 1, "mobile": 1234567890 }
Success (200 OK):
{ "message": "This is your auth token" }
Error (4xx, 5xx):
{ "error": "Error message describing the issue." }
Method: POST
Description:
This endpoint is used for user login.
Request Body Parameters:
- email: (Required) The email address of the user. It must be a valid email format with a maximum length of 255 characters.
- password: (Required) The password of the user. It must be a string with a minimum length of 3 characters.
{ "email": "[email protected]", "password": "secretpassword" }
Success (200 OK):
{ "message": "Login Successful", "token": "generated_token_here" }
Error (4xx, 5xx):
{ "error": "Invalid credentials" }
Method: POST
Description:
This endpoint is used to create a new branch.
Request Body Parameters:
- name: (Required) The name of the branch. It must be a string with a maximum length of 255 characters and must be unique among existing branch names.
- address: (Optional) The address of the branch. It must be a string with a maximum length of 255 characters.
- routing: (Required) The routing number of the branch. It must be an integer.
{ "name": "Branch Name", "address": "Branch Address", "routing": 123456789 }
Success (200 OK):
{ "message": "Branch Name branch created successfully" }
Error (4xx, 5xx):
{ "error": "Error message describing the issue" }
Method: GET
Description:
This endpoint is used to retrieve a list of all branches along with their associated users and tickets.
Success (200 OK):
[ { "id": 1, "name": "Branch 1", "address": "Address 1", "routing": 123456789, "created_at": "2022-03-25T12:00:00Z", "updated_at": "2022-03-25T12:00:00Z", "users": [ { "id": 1, "name": "User 1", "email": "[email protected]", "created_at": "2022-03-25T12:00:00Z", "updated_at": "2022-03-25T12:00:00Z" }, { "id": 2, "name": "User 2", "email": "[email protected]", "created_at": "2022-03-25T12:00:00Z", "updated_at": "2022-03-25T12:00:00Z" } ], "ticket": [ { "id": 1, "subject": "Ticket 1", "details": "Details of Ticket 1", "status": "in_progress", "created_at": "2022-03-25T12:00:00Z", "updated_at": "2022-03-25T12:00:00Z" }, { "id": 2, "subject": "Ticket 2", "details": "Details of Ticket 2", "status": "approved", "created_at": "2022-03-25T12:00:00Z", "updated_at": "2022-03-25T12:00:00Z" } ] }, { "id": 2, "name": "Branch 2", "address": "Address 2", "routing": 987654321, "created_at": "2022-03-25T12:00:00Z", "updated_at": "2022-03-25T12:00:00Z", "users": [], "ticket": [] } ]
Error (4xx, 5xx):
{ "error": "Error message describing the issue" }
Method: POST
Description:
This endpoint is used to update an existing branch with the specified ID.
Path Parameters:
- id: (Required) The ID of the branch to be updated.
Request Body Parameters:
- name: (Optional) The updated name of the branch. It must be a string with a maximum length of 255 characters and must be unique among existing branch names.
- address: (Optional) The updated address of the branch. It must be a string with a maximum length of 255 characters.
- routing: (Optional) The updated routing number of the branch. It must be an integer.
{ "name": "Updated Branch Name", "address": "Updated Branch Address", "routing": 987654321 }
Success (200 OK):
{ "message": "Updated Branch Name updated" }
Error (4xx, 5xx):
{ "error": "Error message describing the issue" }
Method: POST
Description:
This endpoint is used to delete an existing branch with the specified ID.
Path Parameters:
- id: (Required) The ID of the branch to be deleted.
Success (200 OK):
{ "message": "Branch Name deleted" }
Error (4xx, 5xx):
{ "error": "Error message describing the issue" }
Method: GET
Description:
This endpoint is used to retrieve a list of users based on their roles.
Request Body Parameters:
Success (200 OK):
{ "user": [ { "id": 1, "name": "User 1", "email": "[email protected]", "role": "manager", "created_at": "2022-03-25T12:00:00Z", "updated_at": "2022-03-25T12:00:00Z", "tickets": [ { "id": 1, "subject": "Ticket 1", "details": "Details of Ticket 1", "status": "in_progress", "created_at": "2022-03-25T12:00:00Z", "updated_at": "2022-03-25T12:00:00Z" }, { "id": 2, "subject": "Ticket 2", "details": "Details of Ticket 2", "status": "approved", "created_at": "2022-03-25T12:00:00Z", "updated_at": "2022-03-25T12:00:00Z" } ], "branch": { "id": 1, "name": "Branch 1", "address": "Address 1", "routing": 123456789, "created_at": "2022-03-25T12:00:00Z", "updated_at": "2022-03-25T12:00:00Z" } }, { "id": 2, "name": "User 2", "email": "[email protected]", "role": "itdesk", "created_at": "2022-03-25T12:00:00Z", "updated_at": "2022-03-25T12:00:00Z", "tickets": [], "branch": null } ] }
Error (4xx, 5xx):
{ "error": "Error message describing the issue" }
Method: POST
Description:
This endpoint is used to create a new category.
Request Body Parameters:
- title: (Required) The title of the category. It must be a string with a maximum length of 255 characters.
{ "title": "New Category" }
Success (200 OK):
{ "message": "New Category Created successfully" }
Error (4xx, 5xx):
{ "message": "Error message describing the issue" }
Method: GET
Description:
This endpoint is used to retrieve a list of all categories along with their associated subcategories.
Success (200 OK):Returns a JSON array containing information about all categories and their associated subcategories.
[ { "id": 1, "title": "Category 1", "created_at": "2022-03-25T12:00:00Z", "updated_at": "2022-03-25T12:00:00Z", "subcategories": [ { "id": 1, "title": "Subcategory 1", "category_id": 1, "created_at": "2022-03-25T12:00:00Z", "updated_at": "2022-03-25T12:00:00Z" }, { "id": 2, "title": "Subcategory 2", "category_id": 1, "created_at": "2022-03-25T12:00:00Z", "updated_at": "2022-03-25T12:00:00Z" } ] }, { "id": 2, "title": "Category 2", "created_at": "2022-03-25T12:00:00Z", "updated_at": "2022-03-25T12:00:00Z", "subcategories": [] } ]
Error (4xx, 5xx):
{ "error": "You are not authorized to view categories." }