Skip to content

vitornuness/holiday-plans

Repository files navigation

Holiday Plans

This API allows users to manage their holiday plans and download them as PDFs.

Requirements

  • PHP 8.2^
  • Composer 2.7^
  • Docker (with start from Sail)

Summary

  1. Installation
  2. Usage

1. Installation


Local

  1. Clone this repository.
git clone https://github.com/VitorNuness/holiday-plans.git holiday-plans
  1. Access the application folder and install dependencies.
cd holiday-plans
composer install
  1. 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>
  1. Run migrations and generate keys (application and JWT).
php artisan migrate
php artisan key:generate
php artisan jwt:secret
  1. Start the local server.
php artisan serve

Using Laravel Sail (Docker)

  1. Clone this repository.
git clone https://github.com/VitorNuness/holiday-plans.git holiday-plans
  1. Access the application folder and install dependencies.
cd holiday-plans
composer install
  1. 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
  1. Start the container and run migrations.
./vendor/bin/sail up
./vendor/bin/sail artisan migrate

2. Usage

This application is a API RESTful to make CRUD operations for user holiday plans.

Authentication Endpoints

  1. 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
  }
}
  1. 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
  }
}

Holiday Plans Endpoints

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>.

  1. 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
      }
    }
  }
}
  1. 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
}
  1. 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
                }
            ]
        }
    ]
}
  1. 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
      }
    }
  }
}
  1. Delete a specific holiday plan.
  • URI: /api/plans/{int}/delete

  • Method: DELETE

Response

{
  "message": "Delete has been successfully.",
  "data": []
}
  1. Download the holiday plan information in PDF format.
  • URI: /api/plans/{int}/pdf

  • Method: GET

A file 'holiday_plan.pdf' start download.

About

Organize your holiday plans using this API.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages