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);
});
Source by www.itsolutionstuff.com #
 
PREVIOUS NEXT
Tagged: #laravel #factory #relations #data
ADD COMMENT
Topic
Name
3+4 =