►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:-
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 -
Popular Stack Developers Series that can help you:-
►Laravel 11 PostgreSQL Tutorial:
►Laravel 10 Tutorial:
►Laravel Multi-Vendor E-commerce Series -
►React JS Tutorial for Beginners with Laravel -
►Laravel Tutorial for Beginners -
►GIT Tutorial for Beginners -
►Laravel API Tutorial -
►Laravel Interview Questions -
►jQuery Tutorial -
►Laravel Basic E-commerce Series -
►Laravel Dating Series -
►Join this channel to get the complete source code of all series:
Follow Stack Developers on Social Media to get updates and resolve your queries
►Like Facebook Page to get updates -
►Join Facebook Group to resolve your queries -
►Follow on Instagram -
►Follow on GitHub -