Laravel US State Seeder Example (ok)
https://www.itsolutionstuff.com/post/laravel-us-state-seeder-exampleexample.html
C:\xampp\htdocs\reset\database\migrations\2022_05_20_192446_create_us_states_table.php
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateUsStatesTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up() {
Schema::create('us_states', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('code');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down() {
Schema::dropIfExists('us_states');
}
}C:\xampp\htdocs\reset\database\seeders\USStateSeeder.php
C:\xampp\htdocs\reset\app\Models\USState.php

Laravel US State Seeder Example
By Hardik Savani August 11, 2021 Category : LaravelPlayUnmuteLoaded: 1.15%Fullscreen
Today, laravel us state seeder example is our main topic. This article will give you simple example of laravel seeder for us states. Here you will learn laravel us states list. I’m going to show you about laravel us state list. Let's see bellow example how to get us state list in laravel.
Here, i will give you very simple example of how to add us states list using seeder in laravel. we will create table and it store on it. you can also use this example with laravel 6, laravel 7, laravel 8 and laravel 9 version.
Let's see bellow steps:
Step 1: Install Laravel
first of all we need to get fresh Laravel 8 version application using bellow command, So open your terminal OR command prompt and run bellow command:
Step 2: Create Seeder and US State Model
here, we will create migration for us_states table. so let's create migration as bellow:
database/migrations/your_migtion_file.php
now let's run migration:
next, add soft delete facade in user model as like bellow:
app/Models/USState.php
Read Also: Laravel - Example of Database Seeder with insert sample data
Step 3: Create Seeder
In this step, we need to create add seeder for country lists.
Create Seeder with bellow command
database/seeders/USStateSeeder.php
now let's run seeder:
Read Also: Laravel Seeder from CSV File Example
Now you can see records in table:

i hope it can help you...
Last updated
Was this helpful?