A Laravel-based booking API designed to manage and handle property bookings efficiently. Built with modern development practices and a clean architecture.
- User authentication (registration, login, logout) with Laravel Sanctum
- Property management for owners
- Booking management for users
- Integration with Spatie Media Library for photo handling
- Simple property searching functionality
- RESTful API with structured responses
- End-to-end API documentation at
/docs/api
- PHP 8.1+
- Composer
- MySQL 5.7+
- Node.js and npm (for front-end or asset handling via Vite)
Follow the steps below to install and set up the project locally:
-
Clone the Repository
git clone https://github.com/fabyo0/booking-api.git cd booking-api
-
Install PHP Dependencies
composer install
-
Install Node.js Dependencies
npm install
-
Environment Setup Copy the
.env.example
file to.env
and adjust the necessary settings:cp .env.example .env
- Set up your database credentials
- Configure Mail & Queue settings if applicable (
MAIL_*
,QUEUE_CONNECTION
)
-
Generate Application Key
php artisan key:generate
-
Run Database Migrations
php artisan migrate
-
Seed the Database (If Applicable)
php artisan db:seed
-
Run the Application
php artisan serve
Navigate to
http://127.0.0.1:8000
in your browser.
This application provides a comprehensive set of RESTful API endpoints scoped for public and owner-specific operations. Below is a summary of the key endpoints:
HTTP Method | Endpoint | Description |
---|---|---|
POST |
/api/v1/auth/register |
User registration |
POST |
/api/v1/auth/login |
User login |
POST |
/api/v1/logout |
User logout |
HTTP Method | Endpoint | Description |
---|---|---|
GET |
/api/v1/properties/{property} |
View a specific property's details |
GET |
/api/v1/apartments/{apartment} |
View a specific apartment's details (if applicable) |
GET |
/api/v1/search |
Search properties based on filters |
HTTP Method | Endpoint | Description |
---|---|---|
GET |
/api/v1/owner/properties |
List all properties owned by the user |
POST |
/api/v1/owner/properties |
Add a new property |
POST |
/api/v1/owner/{property}/photos |
Add photos to a property |
POST |
/api/v1/owner/{property}/photos/{photo}/reorder/{newPosition} |
Reorder photos for a specific property |
HTTP Method | Endpoint | Description |
---|---|---|
GET |
/api/v1/user/bookings |
List all bookings for the authenticated user |
POST |
/api/v1/user/bookings |
Create a new booking |
GET |
/api/v1/user/bookings/{booking} |
View a specific booking's details |
PUT |
/api/v1/user/bookings/{booking} |
Update a specific booking |
DELETE |
/api/v1/user/bookings/{booking} |
Cancel/delete a specific booking |
Full documentation for all API endpoints, input parameters, and response structures is available at:
http://127.0.0.1:8000/docs/api
You can directly view the documentation in your browser.
The project comes with a PHPUnit test suite. To run tests:
php artisan test
Ensure the .env.testing
file is properly configured before testing.
This API utilizes several industry-standard Laravel packages:
Package | Description |
---|---|
spatie/laravel-medialibrary | Media uploads and handling |
laravel/sanctum | Authentication via tokens |
nunomaduro/larastan | Static analysis for Laravel (improves code quality) |
barryvdh/laravel-ide-helper | Auto-generating PHPDoc for autocomplete support |
dedoc/scramble | API documentation generator for Laravel |
If you discover any security vulnerability, please submit it here or contact the team directly.
This project is open-source software licensed under the MIT License.