Laravel 11 with MongoDB

Published: 06 September 2024
on channel: Stack Developers
40
0

►Laravel 11 Tutorial (with MongoDB):    • Laravel 11 Tutorial (with MongoDB)  

This is Part 108 of the Laravel 11 Tutorial, in which we are building the e-commerce website with Laravel as the front end and MongoDB as the back end. From this part, we will start working on the order placement process.

For placing orders either from COD or Paypal, we need to create orders tables to insert the orders details into them so that admin and user can view orders details anytime they want.

So in this video, we are going to create the below 2 collections with Migration on MongoDB:-

1) orders collection

2) orders_products collection

We will also create model for orders and orders_products tables.

First of all, we will add one condition to check if there are cart items before proceed further to checkout and order placement.

1) Update checkout function :-
We will add condition to check the cart items. If cart items are empty we will redirect the customer back to cart page from checkout.

2) Create orders collection :-
Now, we will create orders collection with migration. "orders" table will contain delivery details, coupon / shipping details, grand total and other main information.

We will create orders collection with below columns and data types:-

So, we will run the below artisan command to create a model and migration file for the orders collection:-
php artisan make:model Order -m

Replace default class with MongoDB Class in DeliveryAddress model:-
use MongoDB\Laravel\Eloquent\Model as Model;

Open the create_orders_table migration file and add all required columns mentioned earlier.

Now, we will run below artisan command to create orders table with required columns :-
php artisan migrate

3) Create orders_products collection :-
Now create an orders_products collection that will have ordered products data that the user going to order.

Create orders_products collection with below columns and data types:-

order_id int(11)
user_id int(11)
product_id int(11)
product_code varchar(255)
product_name varchar(255)
product_color varchar(255)
product_size varchar(255)
product_sku varchar(255)
product_price float
product_qty int(11)
created_at datetime
updated_at timestamp

So, we will run the below artisan command to create model and migration file for orders_products table together:-
php artisan make:model OrdersProduct -m

Replace default class with MongoDB Class in DeliveryAddress model:-
use MongoDB\Laravel\Eloquent\Model as Model;

Open the create_orders_products_table migration file and add all required columns mentioned earlier.

Now, we will run below artisan command to create orders_products table with required columns :-
php artisan migrate

Now our orders tables are ready.

In the next part, we will place order and insert order details in the orders and orders_products tables.

►Click here to subscribe for Laravel & other updates -    / stackdevelopers  

Popular Stack Developers Series that can help you:-

►Laravel 11 PostgreSQL Tutorial:    • Laravel PostgreSQL Tutorial  

►Laravel 10 Tutorial:    • Laravel 10 Tutorial: Make Admin Panel...  

►Laravel Multi-Vendor E-commerce Series -    • Laravel Multi Vendor Tutorial  

►React JS Tutorial for Beginners with Laravel -    • React JS Tutorial with Laravel for Be...  

►Laravel Tutorial for Beginners -    • Laravel Tutorial for Beginners | Adva...  

►GIT Tutorial for Beginners -    • Git Tutorial for Beginners | Create y...  

►Laravel API Tutorial -    • Laravel API Tutorial | Create API fro...  

►Laravel Interview Questions -    • Laravel Interview Questions & Answers...  

►jQuery Tutorial -    • jQuery Tutorial  

►Laravel Basic E-commerce Series -    • Make Admin Panel / E-commerce Website...  

►Laravel Dating Series -    • Make Dating / Social Networking Websi...  

►Join this channel to get the complete source code of all series:
   / @stackdevelopers  

Follow Stack Developers on Social Media to get updates and resolve your queries
►Like Facebook Page to get updates -   / stackdevelopers2  
►Join Facebook Group to resolve your queries -   / stackdevelopers  
►Follow on Instagram -   / stackdevelopers2  
►Follow on GitHub - https://github.com/stackdevelopers

#laravel11 #mongodb #mongodbtutorial


Watch video Laravel 11 with MongoDB online without registration, duration hours minute second in high quality. This video was added by user Stack Developers 06 September 2024, don't forget to share it with your friends and acquaintances, it has been viewed on our site 40 once and liked it 0 people.