in app/Console/Commands/SetupTest.php [327:370]
public function populateRelationships()
{
if (rand(1, 2) == 1) {
foreach (range(1, rand(2, 6)) as $index) {
$gender = (rand(1, 2) == 1) ? 'male' : 'female';
$relatedContact = app(CreateContact::class)->execute([
'account_id' => $this->account->id,
'author_id' => $this->user->id,
'first_name' => $this->faker->firstName($gender),
'last_name' => (rand(1, 2) == 1) ? $this->faker->lastName : null,
'nickname' => (rand(1, 2) == 1) ? $this->faker->name : null,
'gender_id' => $this->getRandomGender()->id,
'is_partial' => rand(1, 2) == 1,
'is_birthdate_known' => false,
'is_deceased' => false,
'is_deceased_date_known' => false,
]);
$relatedContactBirthDate = $this->faker->dateTimeThisCentury();
app(UpdateBirthdayInformation::class)->execute([
'account_id' => $this->account->id,
'contact_id' => $relatedContact->id,
'is_date_known' => rand(1, 2) == 1,
'day' => (int) $relatedContactBirthDate->format('d'),
'month' => (int) $relatedContactBirthDate->format('m'),
'year' => (int) $relatedContactBirthDate->format('Y'),
'is_age_based' => rand(1, 2) == 1,
'age' => rand(1, 99),
'add_reminder' => rand(1, 2) == 1,
'is_deceased' => $relatedContact->is_dead,
]);
// set relationship
$relationshipId = $this->contact->account->relationshipTypes->random()->id;
$relationship = app(CreateRelationship::class)->execute([
'account_id' => $this->account->id,
'contact_is' => $this->contact->id,
'of_contact' => $relatedContact->id,
'relationship_type_id' => $relationshipId,
]);
}
}
}