Laravel 5.2 seed specific data array
I am trying to seed my database with some specific content to get my application started. I am aware of Faker and how to use it (which I do for my Users). Now I want to fill a table with (alot) of records that are not randomly generated, so not created by Faker.
For example I want to have a table with some (lets say 30) clubs so that I can generate a few hundered users who are member of one of those 30 clubs with
Is there another way then to type this 30 times?
$club = Club::create(array( 'name' => 'FC Barcelona', 'number' => '001', ));
Couldn't find this in the laravel (5.2) docs. Only the Faker is explained.
What you can do is creating one array with clubs and seed them and in UsersDatabaseSeeder you can create in loop as many records you want and assign for each of them random club.
$clubs = [['prop1'=> 'val1',], ['prop1' => 'val2']]; \DB::table('clubs')->insert($clubs);
- → "failed to open stream" error when executing "migrate:make"
- → I can't do a foreign key, constraint error
- → Setting a default value on settings form return null in Octobercms
- → Eloquent Multitable query
- → "Laravel 5.1" add user and project with userId
- → Image does not go in database with file name only tmp name saved?
- → Database backup with custom code in laravel 5 and get the data upto 10 rows from per table in database
- → Trait 'IlluminateFoundationBusDispatchesJobs' not found
- → Setting the maxlength of text in an element that is displayed
- → laravel check between 2 integer from database
- → how to retrieve image from database in laravel 5.1?
- → relationship for database Column type object
- → Carousel in Laravel 4 does not show as expected