2025-10-20 08:57:51 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Database\Factories;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
|
|
|
|
|
|
class ContactFactory extends Factory
|
|
|
|
|
{
|
|
|
|
|
protected $model = \App\Models\Contact::class;
|
|
|
|
|
|
|
|
|
|
public function definition()
|
|
|
|
|
{
|
|
|
|
|
// 30% chance of having an avatar, 70% chance of having null
|
|
|
|
|
$hasAvatar = $this->faker->boolean(30);
|
|
|
|
|
|
|
|
|
|
$avatar = null;
|
|
|
|
|
if ($hasAvatar) {
|
|
|
|
|
// Generate a random image ID between 1 and 70 (pravatar.cc has 70 default images)
|
|
|
|
|
$randomImageId = $this->faker->numberBetween(1, 70);
|
|
|
|
|
$avatar = "https://i.pravatar.cc/128?img={$randomImageId}";
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-29 13:53:08 +01:00
|
|
|
$gender = rand(0, 9) >= 5 ? 'female' : 'male';
|
2025-11-04 15:17:23 +01:00
|
|
|
$userName = $this->faker->userName();
|
|
|
|
|
$hasLinkedIn = rand(0, 9) >= 7;
|
|
|
|
|
$hasMatrix = rand(0, 9) >= 7;
|
|
|
|
|
$hasGithub = rand(0, 9) >= 7;
|
|
|
|
|
|
|
|
|
|
$contact = [
|
|
|
|
|
'is_primary' => $this->faker->boolean(30),
|
2025-10-29 13:53:08 +01:00
|
|
|
'salutation' => $this->faker->title($gender),
|
|
|
|
|
'first_name' => $this->faker->firstName($gender),
|
|
|
|
|
'last_name' => $this->faker->lastName($gender),
|
2025-11-04 15:17:23 +01:00
|
|
|
'job_title' => $this->faker->jobTitle(),
|
2025-10-20 08:57:51 +02:00
|
|
|
'email' => $this->faker->unique()->safeEmail(),
|
|
|
|
|
'phone' => $this->faker->phoneNumber(),
|
2025-11-04 15:17:23 +01:00
|
|
|
'mobile_phone' => $this->faker->phoneNumber(),
|
2025-10-20 08:57:51 +02:00
|
|
|
'avatar' => $avatar,
|
2025-11-04 15:17:23 +01:00
|
|
|
'online_accounts' => []
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
if ($hasLinkedIn) $contact[] = [
|
|
|
|
|
'platform' => 'linkedin',
|
|
|
|
|
'user_name' => $userName,
|
|
|
|
|
'url' => 'https://www.linkedin.com/in/' . $userName
|
|
|
|
|
];
|
|
|
|
|
if ($hasMatrix) $contact[] = [
|
|
|
|
|
'platform' => 'matrix',
|
|
|
|
|
'user_name' => $userName,
|
|
|
|
|
'url' => '@' . $userName . ':matrix.org'
|
2025-10-20 08:57:51 +02:00
|
|
|
];
|
2025-11-04 15:17:23 +01:00
|
|
|
if ($hasGithub) $contact[] = [
|
|
|
|
|
'platform' => 'github',
|
|
|
|
|
'user_name' => $userName,
|
|
|
|
|
'url' => 'https://www.github.com/' . $userName
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
return $contact;
|
2025-10-20 08:57:51 +02:00
|
|
|
}
|
|
|
|
|
}
|