FakeContentTableSeeder now adds meaningfull data in ContactFields (#1340)
This commit is contained in:
committed by
Alexis Saettler
parent
643efa1bd6
commit
fe6c05500d
@@ -341,10 +341,43 @@ class FakeContentTableSeeder extends Seeder
|
||||
public function populateContactFields()
|
||||
{
|
||||
if (rand(1, 3) == 1) {
|
||||
for ($j = 0; $j < rand(1, 4); $j++) {
|
||||
|
||||
// Fetch number of types
|
||||
$numberOfTypes = \App\ContactFieldType::count();
|
||||
|
||||
for ($j = 0; $j < rand(1, $numberOfTypes); $j++) {
|
||||
// Retrieve random ContactFieldType
|
||||
$contactFieldType = \App\ContactFieldType::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;
|
||||
}
|
||||
|
||||
$contactField = $this->contact->contactFields()->create([
|
||||
'contact_field_type_id' => rand(1, 6),
|
||||
'data' => $this->faker->url,
|
||||
'contact_field_type_id' => $contactFieldType->id,
|
||||
'data' => $data,
|
||||
'account_id' => $this->contact->account->id,
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user