Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel factory relations data

factory(AppUser::class, 30)->create()->each(function($user) {

    $entity = factory(AppEntity::class)->make();

    $address = factory(AppAddress::class)->create([
        'entity_id' => $entity
    ]);

    $user->entities()->save($entity);
});
 
PREVIOUS NEXT
Tagged: #laravel #factory #relations #data
ADD COMMENT
Topic
Name
1+1 =