Merge branch 'people' of ssh://halbi.ddnss.de:2122/media/raid/repositories/pollux into people
This commit is contained in:
@@ -4,49 +4,36 @@ use Faker\Generator as Faker;
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
|
||||||
$factory->define(App\Person::class, function (Faker $faker) {
|
$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 [
|
return [
|
||||||
'title' => $title,
|
'title' => 'Firma',
|
||||||
'name_or_company' => $name_or_company,
|
'name_or_company' => $faker->company,
|
||||||
'surname' => $surname,
|
|
||||||
'street' => $faker->streetName . ' ' . $faker->buildingNumber,
|
'street' => $faker->streetName . ' ' . $faker->buildingNumber,
|
||||||
'postal_code' => $faker->randomNumber(5, true),
|
'postal_code' => $faker->randomNumber(5, true),
|
||||||
'city' => $faker->city,
|
'city' => $faker->city,
|
||||||
'email' => $faker->safeEmail,
|
'email' => $faker->safeEmail,
|
||||||
'phone' => $faker->numerify('0### / ## ## ## ##'),
|
'phone' => $faker->numerify('0### / ## ## ## ##'),
|
||||||
'mobile' => $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'),
|
'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
|
||||||
'updated_at' => Carbon::now()->format('Y-m-d H:i:s')
|
'updated_at' => Carbon::now()->format('Y-m-d H:i:s')
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$factory->state(App\Person::class, 'male', function ($faker) {
|
||||||
|
return [
|
||||||
|
'title' => 'Herr',
|
||||||
|
'name_or_company' => $faker->lastName,
|
||||||
|
'surname' => $faker->firstName('male'),
|
||||||
|
'date_of_birth' => $faker->dateTimeInInterval($startDate = '-35 years',
|
||||||
|
$interval = '+15 years')
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
$factory->state(App\Person::class, 'female', function ($faker) {
|
||||||
|
return [
|
||||||
|
'title' => 'Frau',
|
||||||
|
'name_or_company' => $faker->lastName,
|
||||||
|
'surname' => $faker->firstName('female'),
|
||||||
|
'date_of_birth' => $faker->dateTimeInInterval($startDate = '-35 years',
|
||||||
|
$interval = '+15 years')
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|||||||
@@ -13,7 +13,9 @@ class TestPeopleTableSeeder extends Seeder
|
|||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
// Create people
|
// Create people
|
||||||
$people = factory(App\Person::class, 100)->create();
|
$people = factory(App\Person::class, 20)->create();
|
||||||
|
$people = $people->concat(factory(App\Person::class, 40)->states('male')->create());
|
||||||
|
$people = $people->concat(factory(App\Person::class, 40)->states('female')->create());
|
||||||
|
|
||||||
// Create random member states for
|
// Create random member states for
|
||||||
// $people->each(function ($person) {
|
// $people->each(function ($person) {
|
||||||
|
|||||||
Reference in New Issue
Block a user