Laravel 11 Tutorial with MongoDB

Опубликовано: 19 Сентябрь 2024
на канале: Stack Developers
51
1

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

This is Part 116 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.

In this part, we will work on updating the order status of every order manually.

We will create order_statuses table with migration and will also add few status in it with Seeding. We will also create model for order statuses.

1) Create order_statuses collection :-
First of all, we will create an order_statuses collection with below columns:-
id, name and status

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

Open create_order_statuses_table migration file and add all required columns mentioned earlier.

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

Now order_statuses table has been created with all the required columns.

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

Now, We will create Seeding for order_statuses table to insert few status from seeder command.

2) Writing Seeder / Create OrderStatusTableSeeder file :-
First of all, we will generate seeder and create OrderStatusTableSeeder file from where we will add few order status for order_statuses table.

Run below artisan command to generate Seeder and create OrderStatusTableSeeder file :-
php artisan make:seeder OrderStatusTableSeeder

Above command will create OrderStatusTableSeeder.php file at \database\seeds\

Now open OrderStatusTableSeeder file and add record for order status.

3) Update DatabaseSeeder.php file :-
Now update DatabaseSeeder.php file located at database/seeds/ to add OrderStatusTableSeeder class as shown in video.

4) Run below commands :-
Now run below commands that will finally insert product into order_statuses table.
composer dump-autoload (if required)
php artisan db:seed --class=OrderStatusTableSeeder

Now we will show order status dynamically in order detail page in admin panel so that the client can manually update the order status when required.

5) Update orderDetails function :-
Now, we will update orderDetails function at OrderController to get all order status from order_statuses table and return to order detail page in the admin panel.

6) Update order_details.blade.php file :-
Now we will update order_details.blade.php file to show all order status dynamically in foreach loop in select option. We will also add form with order_id as hidden.

7) Create Route:-
Now we will create a POST route in the web.php file for updating order status:-
// Update Order Status
Route::post('update-order-status',[OrderController::class,'updateOrderStatus']);

8) Create updateOrderStatus function :-
Now we will create updateOrderStatus function at OrderController to update the order status of particular order and return success message.

9) Update order_details.blade.php file :-
Update the order_details.blade.php file once again to show a success message after updating the order status.

In the next part, we will work on the Order Email that we will send on COD order placement.

►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  

#laravel11 #mongodb #mongodbtutorial


Смотрите видео Laravel 11 Tutorial with MongoDB онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Stack Developers 19 Сентябрь 2024, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 5 раз и оно понравилось людям.