Skip to content

MilenPlamenov/laravel_hotel_bookings_api

Repository files navigation

Bookings Management API

This is a Laravel-based API for managing room bookings, customers, and payments. The API includes features such as room availability checking to prevent double bookings and token-based authentication using Laravel Sanctum.

Table of Contents

Installation

  1. Clone the repository:

    git clone https://github.com/MilenPlamenov/laravel_hotel_bookings_api.git
    cd booking
  2. Install dependencies:

    composer install
  3. Copy the example environment file and configure it:

    cp .env.example .env

    Edit the .env file to match your database and other configurations.

  4. Generate application key:

    php artisan key:generate
  5. Run the migrations and seed the database:

    php artisan migrate --seed
  6. Install Sanctum:

    php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"
    php artisan migrate
  7. Run the application:

    php artisan serve

API Endpoints

Room Management

  • Get all rooms:
    GET /api/rooms
  • Create a room:
    POST /api/rooms
  • Get a single room:
    GET /api/rooms/{id}
  • Update a room:
    PUT /api/rooms/{id}
  • Delete a room:
    DELETE /api/rooms/{id}

Booking Management

  • Get all bookings:
    GET /api/bookings
  • Create a booking:
    POST /api/bookings
  • Get a single booking:
    GET /api/bookings/{id}
  • Update a booking:
    PUT /api/bookings/{id}
  • Delete a booking:
    DELETE /api/bookings/{id}

Payment Management

  • Get all payments:
    GET /api/payments
  • Create a payment:
    POST /api/payments
  • Get a single payment:
    GET /api/payments/{id}
  • Update a payment:
    PUT /api/payments/{id}
  • Delete a payment:
    DELETE /api/payments/{id}

Auth Management

  • Register:
    POST /api/register
  • Login:
    POST /api/login
  • Logout:
    POST /api/logout

Testing

  • Unit tests for all controllers (Auth, Booking, Room and Payment)
    php artisan test

About

Rest API for hotel bookings with token based auth

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published