MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

How to Store Countries, States, Cities seed classes into the Database in Laravel PHP? (Part-1)

How to Store Countries, States, Cities seed classes into the Database in Laravel PHP?

Part- 2 Part- 3

Laravel DropDown Feature page with empty Country, State and City select fields

Step 1. Create a Country seeder file. Write down the following command as follows:

$  php artisan make:seeder CountriesTableSeeder
Git Bash running php artisan make:seeder CountriesTableSeeder with Seeder created successfully

Step 2. Create a Country model. Write down the following command as follows:

$  php artisan make:model Country -m
Git Bash terminal running php artisan make:model Country -m after creating the seeder

Step 3. Add columns into Country table.

 public function up()
    {
        Schema::create('countries', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('sort');
            $table->string('country_name');
            $table->integer('phoneCode');
            $table->timestamps();
        });
    }Code language: PHP (php)

Step 4. Now, Go to Database/seeds/CountriesTableSeeder file.

Step 5. After that Go to Database/seeds/DatabaseSeeder file. Write down the following command as follows:

 public function run()
    {
        $this->call(CountriesTableSeeder::class);
    }Code language: PHP (php)

Step 6. Migrate the tables into the MySQL database.

$ php artisan migrate

Step 7. Run the seeder class file individually.

$  php artisan db:seed --class=CountriesTableSeeder
Code language: JavaScript (javascript)
Git Bash terminal running php artisan db:seed --class=CountriesTableSeeder

Step 8. Go to Database/seeds/CountriesTableSeeder.php file

Step 9. Then, go to routes/web.php file and define all these routes.

Route::get('/','MainController@index');Code language: PHP (php)
DropDown Feature Country select expanded, listing seeded countries from Afghanistan onward

Thanks

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
With MotoShare.in, you can book a bike instantly, enjoy doorstep delivery, and ride without worries. Perfect for travelers, professionals, and adventure enthusiasts looking for a seamless mobility solution.

Related Posts

How to display a table in a Verticle or Horizontal form in the Laravel PHP Framework? Part-1

How to display a table in a Verticle or Horizontal form in the Laravel PHP Framework? How to Store Seed file into Database. Click There are two…

Read More

HOW TO CREATE EVENT CALENDAR IN LARAVEL? PART-3

Step 1.Create a Database in phpMyAdmin. (Write the same name of database which was written in .enf databse name). Step 2.  We use the migrate command to…

Read More

HOW TO CREATE EVENT CALENDAR IN LARAVEL? PART-2

Step 1.Create a Laravel Project Firstly, Create a new project in laravel, so we open Git Bash,  Go to My Computer/This PC–>LocalDisk(C:)–>Xampp–>Htdocs (Press right click on Mouse)…

Read More

How to file upload in DB With local folder using laravel 5.8

Step:1 you have to make these(A) – php artisan make:controller ImageUploadController(B) – php artisan make:model ImageUpload -m Step:2 Open the welcome.blade.php page then write this code. Step:3…

Read More

How to Store Countries, States, Cities seed classes into the Database in Laravel PHP? (Part-3)

How to Store Countries, States, Cities seed classes into the Database in Laravel PHP Part-1 Part- 2 Step 1. Create a City seeder file. Write down the…

Read More

How to Store Countries, States, Cities seed classes into the Database in Laravel PHP? (Part-2)

How to Store Countries, States, Cities seed classes into the Database in Laravel PHP? Part-1 Part-3 Step 1. Create a State seeder file. Write down the following…

Read More