This project is the sample project used as part of the Laravel Transactions Learning Bytes on MongoDB learning platform.
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
- Simple, fast routing engine.
- Powerful dependency injection container.
- Multiple back-ends for session and cache storage.
- Expressive, intuitive database ORM.
- Database agnostic schema migrations.
- Robust background job processing.
- Real-time event broadcasting.
Laravel is accessible, powerful, and provides tools required for large, robust applications.
This repository contains the code for a sample application demonstrating the use of MongoDB transactions with Laravel. The application simulates a rental service for different types of items.
Before running the application, ensure you have the following installed:
- PHP 7.3 or higher
- Composer
- Laravel 6.x or higher
- MongoDB Atlas account and cluster
- MongoDB PHP driver
Follow these steps to set up and run the application:
-
Clone the repository:
git clone https://github.com/mongodb-developer/laravel-transaction-rentals.git cd laravel-transaction-rentals -
Install dependencies:
composer install -
Set up environment variables:
Copy the
.env.examplefile to.envand update the MongoDB Atlas connection settings.cp .env.example .envUpdate the following variables in the
.envfile with your MongoDB Atlas connection details:DB_URI="..."You will find your MongoDB Atlas connection string in the Atlas UI under "Connect".
In your database use "sample_airbnb.rentals" collection.
-
Use Atlas data explorer to upload the following rentals.json array into the "Insert Document" json array to upload initial rentals
-
We can use the mongosh shell to insert some data into the rentals collection.
To run the application, use the following command:
php artisan serve
Visit http://localhost:8000 in your web browser to access the application.
- Transaction Management: Demonstrates the use of MongoDB transactions for rental operations.
Item: Represents an item available for rent.Rental: Represents a rental transaction.User: Represents a user in the system.
ItemController: Manages the CRUD operations for items.RentalController: Manages the rental transactions.
web.php: Contains the web routes for the application.
Contributions are welcome! Please submit a pull request for any changes you would like to make.
This project is licensed under the MIT License. See the LICENSE file for details.
This project is maintained by the MongoDB Developer team. For more information, visit the official website.