- PHP 8.2^
- Composer 2.7^
- Docker (with start from Sail)
- Clone this repository.
git clone https://github.com/VitorNuness/holiday-plans.git holiday-plans
- Access the application folder and install dependencies.
cd holiday-plans
composer install
- Define environment variables.
cp .env.example .env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=holiday_plans
DB_USERNAME=<your_username>
DB_PASSWORD=<your_password>
- Run migrations and generate keys (application and JWT).
php artisan migrate
php artisan key:generate
php artisan jwt:secret
- Start the local server.
php artisan serve
- Clone this repository.
git clone https://github.com/VitorNuness/holiday-plans.git holiday-plans
- Access the application folder and install dependencies.
cd holiday-plans
composer install
- Define environment variables and generate keys (application ans JWT).
cp .env.example .env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=holiday_plans
DB_USERNAME=<your_username>
DB_PASSWORD=<your_password>
php artisan key:generate
php artisan jwt:secret
- Start the container and run migrations.
./vendor/bin/sail up
./vendor/bin/sail artisan migrate
- Register a new user.
-
URI: /api/auth/register
-
Method: POST
Request
{
"name": string,
"email": string,
"password": date,
"password_confirmation": string
}
Response
{
"message": "Register as been successfully.",
"data": {
"user": {
"name": string,
"email": string
},
"token": string
}
}
- User login.
-
URI: /api/auth/login
-
Method: POST
Request
{
"email": string,
"password": string
}
Response
{
"message": "Login as been successfully.",
"data": {
"user": {
"name": string,
"email": string
},
"token": string
}
}
To access this Holiday Plans methods the user has been authenticated and has the plan owner.
The methods is necessary the header has: 'Authorization': Bearer <token>
.
- Create a new Holiday Plan.
-
URI: /api/plans/new
-
Method: POST
Request
{
"title": string,
"description": string,
"date": date,
"location": string,
"participants": array
}
Response
{
"message": "Holiday Plan has been created successfully!",
"data": {
"id": string,
"title": string,
"description": string,
"date": date,
"location": string,
"participants": array,
"created_by": {
"user" : {
"name": string,
"email": string
}
}
}
}
- Retrieve all holiday plans paginated.
-
URI: /api/plans
-
Method: GET
Response
{
"current_page": int,
"data": [
{
"message": "Holiday Plan has been created successfully!",
"data": {
"id": string,
"title": string,
"description": string,
"date": date,
"location": string,
"participants": array,
"created_by": {
"user" : {
"name": string,
"email": string
}
}
}
}
],
"first_page_url": string,
"from": string,
"last_page": int,
"last_page_url": string,
"links": [
{
"url": string,
"label": string,
"active": boolean
},
{
"url": string,
"label": string,
"active": boolean
},
{
"url": string,
"label": string,
"active": boolean
}
],
"next_page_url": string,
"path": string,
"per_page": int,
"prev_page_url": string,
"to": string,
"total": int
}
- Get a specific holiday plan.
-
URI: /api/plans/{int}
-
Method: GET
Response
{
data: [
{
"id": string,
"title": string,
"description": string,
"date": date,
"location": string,
"participants": array,
"created_by": [
{
"name": string,
"email": string
}
]
}
]
}
- Update a specific holiday plan.
-
URI: /api/plans/{int}/update
-
Method: PUT
Request
{
"title": string,
"description": string,
"date": date,
"location": string,
"participants": array
}
Response
{
"message": "Update has been successfully!",
"data": {
"id": string,
"title": string,
"description": string,
"date": date,
"location": string,
"participants": array,
"created_by": {
"user" : {
"name": string,
"email": string
}
}
}
}
- Delete a specific holiday plan.
-
URI: /api/plans/{int}/delete
-
Method: DELETE
Response
{
"message": "Delete has been successfully.",
"data": []
}
- Download the holiday plan information in PDF format.
-
URI: /api/plans/{int}/pdf
-
Method: GET
A file 'holiday_plan.pdf' start download.