laravel factory index code example
Example 1: laravel factory
php artisan make:factory PostFactory --model=Post
Example 2: laravel factory relations data
factory(App\User::class, 30)->create()->each(function($user) {
$entity = factory(App\Entity::class)->make();
$address = factory(App\Address::class)->create([
'entity_id' => $entity
]);
$user->entities()->save($entity);
});