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);
});
// If you factory is out of standard, you can set an specifc
// On your model, create a static method named newFactory
protected static function newFactory()
{
return DatabaseFactoriesMyModelFactory::new();
}
//On your factory, add this
protected $model = AppModelsMyModel::class;