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')
|
||||||
|
];
|
||||||
|
});
|
||||||
@@ -13,8 +13,8 @@ class TestDataSeeder extends Seeder
|
|||||||
{
|
{
|
||||||
$this->call([
|
$this->call([
|
||||||
TestBookingsTableSeeder::class,
|
TestBookingsTableSeeder::class,
|
||||||
TestMemberStatesTableSeeder::class,
|
|
||||||
TestPeopleTableSeeder::class,
|
TestPeopleTableSeeder::class,
|
||||||
|
TestMemberStatesTableSeeder::class,
|
||||||
TestPersonTargetsTableSeeder::class,
|
TestPersonTargetsTableSeeder::class,
|
||||||
TestProjectsTableSeeder::class,
|
TestProjectsTableSeeder::class,
|
||||||
TestSubBookingsTableSeeder::class
|
TestSubBookingsTableSeeder::class
|
||||||
|
|||||||
@@ -12,46 +12,6 @@ class TestPeopleTableSeeder extends Seeder
|
|||||||
*/
|
*/
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
DB::table('people')->insert([
|
factory(App\Person::class, 100)->create();
|
||||||
[
|
|
||||||
'title' => 'Herr',
|
|
||||||
'name_or_company' => 'Halbritter',
|
|
||||||
'surname' => 'Lukas',
|
|
||||||
'street' => 'Stefan-Meier-Straße 63',
|
|
||||||
'postal_code' => '79104',
|
|
||||||
'city' => 'Freiburg',
|
|
||||||
'email' => 'halbi93@gmx.de',
|
|
||||||
'mobile' => '0174 / 78 14 6 97',
|
|
||||||
'date_of_birth' => '1993-05-27',
|
|
||||||
'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
|
|
||||||
'updated_at' => Carbon::now()->format('Y-m-d H:i:s')
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'title' => 'Frau',
|
|
||||||
'name_or_company' => 'Strobel',
|
|
||||||
'surname' => 'Max-Brit',
|
|
||||||
'street' => 'Haslacher Straße 79',
|
|
||||||
'postal_code' => '79106',
|
|
||||||
'city' => 'Freiburg',
|
|
||||||
'email' => 'majbrit.strobel@googlemail.de',
|
|
||||||
'mobile' => null,
|
|
||||||
'date_of_birth' => '1992-01-14',
|
|
||||||
'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
|
|
||||||
'updated_at' => Carbon::now()->format('Y-m-d H:i:s')
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'title' => 'Herr',
|
|
||||||
'name_or_company' => 'Mustermann',
|
|
||||||
'surname' => 'Max',
|
|
||||||
'street' => 'Musterstraße 1234',
|
|
||||||
'postal_code' => '12345',
|
|
||||||
'city' => 'Musterstad',
|
|
||||||
'email' => 'max@mustermann.de',
|
|
||||||
'mobile' => null,
|
|
||||||
'date_of_birth' => '1990-07-03',
|
|
||||||
'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
|
|
||||||
'updated_at' => Carbon::now()->format('Y-m-d H:i:s')
|
|
||||||
]
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,14 +18,14 @@ class TestProjectsTableSeeder extends Seeder
|
|||||||
[
|
[
|
||||||
'name' => 'Wintersemester 2014',
|
'name' => 'Wintersemester 2014',
|
||||||
'start_date' => '2014-09-01',
|
'start_date' => '2014-09-01',
|
||||||
'end_date' => '2015-02-28'
|
'end_date' => '2015-02-28',
|
||||||
'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')
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => 'Sommersemester 2015',
|
'name' => 'Sommersemester 2015',
|
||||||
'start_date' => '2015-03-01',
|
'start_date' => '2015-03-01',
|
||||||
'end_date' => '2015-08-31'
|
'end_date' => '2015-08-31',
|
||||||
'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')
|
||||||
],
|
],
|
||||||
@@ -34,14 +34,14 @@ class TestProjectsTableSeeder extends Seeder
|
|||||||
[
|
[
|
||||||
'name' => 'Wintersemester 2018',
|
'name' => 'Wintersemester 2018',
|
||||||
'start_date' => '2018-09-01',
|
'start_date' => '2018-09-01',
|
||||||
'end_date' => '2019-02-28'
|
'end_date' => '2019-02-28',
|
||||||
'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')
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => 'Projekt WiSe 2018',
|
'name' => 'Projekt WiSe 2018',
|
||||||
'start_date' => '2018-09-10',
|
'start_date' => '2018-09-10',
|
||||||
'end_date' => '2018-12-31'
|
'end_date' => '2018-12-31',
|
||||||
'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')
|
||||||
],
|
],
|
||||||
@@ -50,14 +50,14 @@ class TestProjectsTableSeeder extends Seeder
|
|||||||
[
|
[
|
||||||
'name' => 'Sommersemester 2019',
|
'name' => 'Sommersemester 2019',
|
||||||
'start_date' => '2019-03-01',
|
'start_date' => '2019-03-01',
|
||||||
'end_date' => '2019-08-31'
|
'end_date' => '2019-08-31',
|
||||||
'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')
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => 'Projekt SoSe 2019',
|
'name' => 'Projekt SoSe 2019',
|
||||||
'start_date' => '2019-05-01',
|
'start_date' => '2019-05-01',
|
||||||
'end_date' => '2019-05-31'
|
'end_date' => '2019-05-31',
|
||||||
'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')
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user