You could use factories. https://laravel.com/docs/5.3/seeding If you pass an array in to the make and create methods they will get merged in to the data array the factory generated. If you use that along with faker you'll be fine
$category = factory(App\Category::class);
factory(App\User::class, 50)->create([
'name' => 'jon',
'category' => $category->id
])->each(function($u) {
$u->posts()->save(factory(App\Post::class)->make(['title' => 'test']));
});
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community