Turn Your Vehicle Into a Smart Earning Asset

While you’re not driving your car or bike, it can still be working for you. MOTOSHARE helps you earn passive income by connecting your vehicle with trusted renters in your city.

πŸš— You set the rental price
πŸ” Secure bookings with verified renters
πŸ“ Track your vehicle with GPS integration
πŸ’° Start earning within 48 hours

Join as a Partner Today

It’s simple, safe, and rewarding. Your vehicle. Your rules. Your earnings.

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 command as follows:

$  php artisan make:seeder StatesTableSeeder

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

$  php artisan make:model State -m

Step 3. Add columns into Country table.

 public function up()
    {
        Schema::create('states', function (Blueprint $table) {
           $table->bigIncrements('state_id');
            $table->string('state_name');
            $table->integer('country_id');
            $table->timestamps();
        });
    }Code language: PHP (php)

Step 4. Go to Database/seeds/DatabaseSeeder file. Write down the following command as follows to add State seeder class:

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

Step 5. Go to Database/seeds/CountriesTableSeeder file.

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=StatesTableSeederCode language: JavaScript (javascript)

Step 8. Go to app\http\Controllers\MainController.php file. Define funcitions of Country and State.

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

Route::get('/getStates/{id}','MainController@getStates');Code language: JavaScript (javascript)

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.