Added person factory.
Fixed missing comma in TestProjectsTableSeeder.
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
use Carbon\Carbon;
|
||||
|
||||
$factory->define(App\Person::class, function (Faker $faker) {
|
||||
$title = null;
|
||||
$name_or_company = null;
|
||||
$surname = null;
|
||||
$date_of_birth = null;
|
||||
|
||||
// Decide randomly, if we create a person or a company and fill the
|
||||
// differing fields accordingly
|
||||
$probComp = 0.3;
|
||||
$rand = $faker->numberBetween(0, $max = 1000);
|
||||
|
||||
if ($rand <= (int) ($probComp * $max)) {
|
||||
$title = 'Firma';
|
||||
$name_or_company = $faker->company;
|
||||
} else {
|
||||
$probMale = 0.5;
|
||||
$rand = $faker->numberBetween(0, $max = 1000);
|
||||
|
||||
if ($rand <= (int) ($probComp * $max)) {
|
||||
$title = 'Herr';
|
||||
$surname = $faker->firstName('male');
|
||||
} else {
|
||||
$title = 'Frau';
|
||||
$surname = $faker->firstName('female');
|
||||
}
|
||||
|
||||
$name_or_company = $faker->lastName;
|
||||
$date_of_birth = $faker->dateTimeInInterval($startDate = '-35 years',
|
||||
$interval = '+15 years');
|
||||
}
|
||||
|
||||
return [
|
||||
'title' => $title,
|
||||
'name_or_company' => $name_or_company,
|
||||
'surname' => $surname,
|
||||
'street' => $faker->streetName . ' ' . $faker->buildingNumber,
|
||||
'postal_code' => $faker->randomNumber(5, true),
|
||||
'city' => $faker->city,
|
||||
'email' => $faker->safeEmail,
|
||||
'phone' => $faker->numerify('0### / ## ## ## ##'),
|
||||
'mobile' => $faker->numerify('0### / ## ## ## ##'),
|
||||
'date_of_birth' => $faker->dateTimeInInterval($startDate = '-35 years',
|
||||
$interval = '+15 years'),
|
||||
'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
|
||||
'updated_at' => Carbon::now()->format('Y-m-d H:i:s')
|
||||
];
|
||||
});
|
||||
Reference in New Issue
Block a user