I don't know of one but I would just cut and paste a list from the web into an array and do a foreach to seed them.
Hi Kenold,
It depends on the number and nature of fields you need.
Only state and state code, or more information is needed?
@thestepafter: I did that with MySQL; I thought there was an easier way to do that in Laravel @codeATbusiness: I'll need all 50 US states with "abbreviation" and "state_name": Ex: FL, Florida
If you are looking for test seeds have a look at Faker. Its en_US provider contains states, codes and more. Probably it can be used to generate the correct list, too?
I made it only with two fields name and code:
<?php
class SeedStatesUS extends Seeder {
public function run() {
DB::table('us_states')->insert(
array(
array('name' => 'Alabama', 'code' => 'AL'),
array('name' => 'Alaska', 'code' => 'AK'),
array('name' => 'Arizona', 'code' => 'AZ'),
array('name' => 'Arkansas', 'code' => 'AR'),
array('name' => 'California', 'code' => 'CA'),
array('name' => 'Colorado', 'code' => 'CO'),
array('name' => 'Connecticut', 'code' => 'CT'),
array('name' => 'Delaware', 'code' => 'DE'),
array('name' => 'District of Columbia', 'code' => 'DC'),
array('name' => 'Florida', 'code' => 'FL'),
array('name' => 'Georgia', 'code' => 'GA'),
array('name' => 'Hawaii', 'code' => 'HI'),
array('name' => 'Idaho', 'code' => 'ID'),
array('name' => 'Illinois', 'code' => 'IL'),
array('name' => 'Indiana', 'code' => 'IN'),
array('name' => 'Iowa', 'code' => 'IA'),
array('name' => 'Kansas', 'code' => 'KS'),
array('name' => 'Kentucky', 'code' => 'KY'),
array('name' => 'Louisiana', 'code' => 'LA'),
array('name' => 'Maine', 'code' => 'ME'),
array('name' => 'Maryland', 'code' => 'MD'),
array('name' => 'Massachusetts', 'code' => 'MA'),
array('name' => 'Michigan', 'code' => 'MI'),
array('name' => 'Minnesota', 'code' => 'MN'),
array('name' => 'Mississippi', 'code' => 'MS'),
array('name' => 'Missouri', 'code' => 'MO'),
array('name' => 'Montana', 'code' => 'MT'),
array('name' => 'Nebraska', 'code' => 'NE'),
array('name' => 'Nevada', 'code' => 'NV'),
array('name' => 'New Hampshire', 'code' => 'NH'),
array('name' => 'New Jersey', 'code' => 'NJ'),
array('name' => 'New Mexico', 'code' => 'NM'),
array('name' => 'New York', 'code' => 'NY'),
array('name' => 'North Carolina', 'code' => 'NC'),
array('name' => 'North Dakota', 'code' => 'ND'),
array('name' => 'Ohio', 'code' => 'OH'),
array('name' => 'Oklahoma', 'code' => 'OK'),
array('name' => 'Oregon', 'code' => 'OR'),
array('name' => 'Pennsylvania', 'code' => 'PA'),
array('name' => 'Rhode Island', 'code' => 'RI'),
array('name' => 'South Carolina', 'code' => 'SC'),
array('name' => 'South Dakota', 'code' => 'SD'),
array('name' => 'Tennessee', 'code' => 'TN'),
array('name' => 'Texas', 'code' => 'TX'),
array('name' => 'Utah', 'code' => 'UT'),
array('name' => 'Vermont', 'code' => 'VT'),
array('name' => 'Virginia', 'code' => 'VA'),
array('name' => 'Washington', 'code' => 'WA'),
array('name' => 'West Virginia', 'code' => 'WV'),
array('name' => 'Wisconsin', 'code' => 'WI'),
array('name' => 'Wyoming', 'code' => 'WY')
));
}
}
Just call from the DatabaseSeeder.php and use the CLI command php artisan db:seed
NOTE. I'm fixed the list that i used in the last sent.
Hope it helps you.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community