Skip to content

mongodb-developer/laravel-transaction-rentals

Repository files navigation

Laravel Transaction Rentals

This project is the sample project used as part of the Laravel Transactions Learning Bytes on MongoDB learning platform.

Laravel Logo

Build Status Total Downloads Latest Stable Version License

About Laravel

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:

MongoDB Laravel Integration

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.

Prerequisites

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

Installation

Follow these steps to set up and run the application:

  1. Clone the repository:

    git clone https://github.com/mongodb-developer/laravel-transaction-rentals.git
    cd laravel-transaction-rentals
    
  2. Install dependencies:

    composer install
    
  3. Set up environment variables:

    Copy the .env.example file to .env and update the MongoDB Atlas connection settings.

    cp .env.example .env
    

    Update the following variables in the .env file with your MongoDB Atlas connection details:

     DB_URI="..."
    

    You will find your MongoDB Atlas connection string in the Atlas UI under "Connect".

Load the dataset

In your database use "sample_airbnb.rentals" collection.

  1. Use Atlas data explorer to upload the following rentals.json array into the "Insert Document" json array to upload initial rentals

  2. We can use the mongosh shell to insert some data into the rentals collection.

Usage

To run the application, use the following command:

php artisan serve

Visit http://localhost:8000 in your web browser to access the application.

Features

  • Transaction Management: Demonstrates the use of MongoDB transactions for rental operations.

Code Overview

Models

  • Item: Represents an item available for rent.
  • Rental: Represents a rental transaction.
  • User: Represents a user in the system.

Controllers

  • ItemController: Manages the CRUD operations for items.
  • RentalController: Manages the rental transactions.

Routes

  • web.php: Contains the web routes for the application.

Contributing

Contributions are welcome! Please submit a pull request for any changes you would like to make.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgements

This project is maintained by the MongoDB Developer team. For more information, visit the official website.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published