Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel seeder with relationships

factory(User::class, 10)->create()->each(function ($user) {
    $user->posts()->saveMany(factory(Posts::class, 5)->make());
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #laravel #seeder #relationships
ADD COMMENT
Topic
Name
7+8 =