in app/Console/Commands/SetupTest.php [495:539]
public function populateContactFields()
{
if (rand(1, 3) == 1) {
// Fetch number of types
$numberOfTypes = ContactFieldType::where('account_id', $this->account->id)->count();
for ($j = 0; $j < rand(1, $numberOfTypes); $j++) {
// Retrieve random ContactFieldType
$contactFieldType = ContactFieldType::where('account_id', $this->account->id)->orderBy(DB::raw('RAND()'))->firstOrFail();
// Fake data according to type
$data = null;
switch ($contactFieldType->name) {
case 'Email':
$data = $this->faker->email;
break;
case 'Phone':
$data = $this->faker->phoneNumber;
break;
case 'Facebook':
$data = 'https://facebook.com/'.$this->faker->userName;
break;
case 'Twitter':
$data = 'https://twitter.com/'.$this->faker->userName;
break;
case 'Whatsapp':
$data = $this->faker->phoneNumber;
break;
case 'Telegram':
$data = $this->faker->phoneNumber;
break;
default:
$data = $this->faker->url;
break;
}
$this->contact->contactFields()->create([
'contact_field_type_id' => $contactFieldType->id,
'data' => $data,
'account_id' => $this->account->id,
]);
}
}
}