Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

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();
        });
    }

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);
    }

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

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');

Thanks

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.