This is a RESTful API for an escape room booking system built with Laravel. The system allows users to view available escape rooms, book time slots, and manage their bookings.
The BookingController in this project follows the Repository design pattern. The Repository pattern is used to separate the data access logic from the business logic of the application. It provides a layer of abstraction for data persistence and retrieval.
By utilizing the Repository pattern, the BookingController interacts with a dedicated BookingRepository class to perform CRUD (Create, Read, Update, Delete) operations on the bookings data. This helps in decoupling the controller from the underlying data storage mechanism, making it easier to switch between different data sources or ORM frameworks in the future.
The BookingRepository class implements methods for querying and manipulating the bookings data, encapsulating the underlying data access details and providing a clean and consistent API for the controller to work with.
The use of the Repository pattern promotes code reusability, testability, and maintainability by providing a clear separation of concerns between the different layers of the application.
To run this project locally, follow these steps:
- Clone the repository
- Install the dependencies:
composer install - Set up the environment variables: Create a copy of the
.env.examplefile and rename it to.env. Modify the file to add the necessary configurations for your local environment. - Generate an application key:
php artisan key:generate - Run the database migrations:
php artisan migrate - Start the development server:
php artisan serve
In order to create fake data at the same time (Laravel Facroey), you can use php artisan migrate:fresh --seed command instead of php artisan migrate
GET /escape-rooms: Retrieve a list of all escape rooms.GET /escape-rooms/{id}: Retrieve details of a specific escape room by its ID.GET /escape-rooms/{id}/time-slots: Retrieve available time slots for a specific escape room.POST /bookings: Create a new booking for a specific escape room and time slot.GET /bookings: Retrieve all bookings for the authenticated user.DELETE /bookings/{id}: Cancel a specific booking by its ID.
It is recommended to use the Postman program for checking.
The Postman output file is placed in the root directory
Import the file to test.
To login, enter the e-mail and password in the previously created database and enter the output token as Bearer Token in the authentication section. Paths to bookings all require authentication
The database schema for this project includes tables for users, escape_rooms, time_slots, and bookings. The relationships between these tables are defined in the respective models.
Authentication is implemented using Laravel's built-in authentication features (Laravel Sanctum). Users can register, log in, and manage their profiles. User information such as name, email, and date of birth is stored securely.
This project includes unit tests to ensure the correctness and reliability of the API. You can run the tests using the following command: php artisan test
For any questions or inquiries, feel free to reach out to me:
- Name: [Reza Mahmudi Moghadam]
- Email: [dr.fet91@gmail.com]
- Social Media: linkedin
I'm interested in reading your comments and messages, and I'm available for collaboration if needed.