Laravel 11 with MongoDB #95 | User Account Page (II) | Create countries Collection | Show Select Box

Published: 01 January 1970
on channel: Stack Developers
41
2

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

This is Part 95 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. We will continue working on user account page functionality via Ajax.

In this part, we will create a countries collection and will show the countries select box on the user contact/billing form.

1) Create countries collection:-
We will create a countries collection in MongoDB with the below columns:-
country_code, country_name and status

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

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

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

Now, we will run the artisan command to create a banners table with the required columns:-
php artisan migrate

Now countries collection has been created with all the required columns.

2) Import countries data:-
Now, we will search and import countries data into countries collection. We can search in Google for keyword like "countries csv" and open the below link:-
https://github.com/umpirsky/country-l...

We will modify country.csv column names to country_code and country_name and add a status column with 1 value for all. Finally, we will import this file into our countries collection.

3) Update account function:-
Now we will get all countries from the countries table in the account function in UserController and return to the account blade file.

4) Include Country model:-
Include the Country model at the top of UserController like below:-
use App\Models\Country;

5) Update account.blade.php file:-
Now we will replace the country text field with a select box and add foreach loop to show all countries in the countries select box in the user account form.
In the next part, we will work on change password functionality.

Thanks for watching :)

►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 #95 | User Account Page (II) | Create countries Collection | Show Select Box online without registration, duration hours minute second in high quality. This video was added by user Stack Developers 01 January 1970, don't forget to share it with your friends and acquaintances, it has been viewed on our site 41 once and liked it 2 people.