Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

“Invest in yourself — your confidence is always worth it.”

Explore Cosmetic Hospitals

Start your journey today — compare options in one place.

|

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

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

$  php artisan make:seeder CountriesTableSeeder

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

$  php artisan make:model Country -m

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)

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)

Thanks

Find Trusted Cardiac Hospitals

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

Explore Hospitals

Similar Posts