diff --git a/database/seeds/data/test/TestMemberStatesTableSeeder.php b/database/seeds/data/test/TestMemberStatesTableSeeder.php index d9cdcb0..301b89d 100644 --- a/database/seeds/data/test/TestMemberStatesTableSeeder.php +++ b/database/seeds/data/test/TestMemberStatesTableSeeder.php @@ -12,36 +12,12 @@ class TestMemberStatesTableSeeder extends Seeder */ public function run() { - /*DB::table('member_states')->insert([ - [ - 'person_id' => 1, - 'joining_date' => '2014-9-22', - 'leaving_date' => '2014-12-31', - 'created_at' => Carbon::now()->format('Y-m-d H:i:s'), - 'updated_at' => Carbon::now()->format('Y-m-d H:i:s') - ], - [ - 'person_id' => 1, - 'joining_date' => '2015-1-1', - 'leaving_date' => null, - 'created_at' => Carbon::now()->format('Y-m-d H:i:s'), - 'updated_at' => Carbon::now()->format('Y-m-d H:i:s') - ], - [ - 'person_id' => 2, - 'joining_date' => '2014-9-22', - 'leaving_date' => null, - 'created_at' => Carbon::now()->format('Y-m-d H:i:s'), - 'updated_at' => Carbon::now()->format('Y-m-d H:i:s') - ] - ]);*/ - // Iterate through existing People and randomly assign their ids // once or twice. foreach (App\Person::all() as $person) { // randomly decide if person has a state. - $personHasState = rand(1,8) < 8; + $personHasState = rand_bool(88); if($personHasState) { // if Person has a State, decide if it has one or two. @@ -58,14 +34,14 @@ class TestMemberStatesTableSeeder extends Seeder public function createPerson($id, $numberOfStates = 1) { - // manually create faker Instance since you can't control iterations + // Manually create faker Instance since you can't control iterations // in Factory-Files. $faker = Faker\Factory::create(); $startDate = "2014-04-01"; if($numberOfStates > 1) { - // if member has 2 states, the first one must be a few years in the past. + // If member has 2 states, the first one must be a few years in the past. $lastLeaving = "2015-12-30"; $firstSecondJoiningDate = "2017-06-01"; @@ -73,9 +49,9 @@ class TestMemberStatesTableSeeder extends Seeder $firstLeavingDate = $faker->dateTimeBetween($firstJoiningDate, $lastLeaving); $secondJoiningDate = $faker->dateTimeBetween($firstSecondJoiningDate, 'now'); - $secondLeavingDate = NULL; - if(rand(1,8) === 8) - { + $secondLeavingDate = null; + + if (rand_bool(12)) { $secondLeavingDate = $faker->dateTimeBetween($secondJoiningDate, 'now'); } @@ -92,11 +68,12 @@ class TestMemberStatesTableSeeder extends Seeder ]); } else { $joiningDate = $faker->dateTimeBetween($startDate, 'now - 30 days'); - $leavingDate = NULL; - if(rand(1,5) === 5) - { + $leavingDate = null; + + if (rand_bool(20)) { $leavingDate = $faker->dateTimeBetween($joiningDate, 'now'); } + factory(App\MemberState::class, 1)->create([ 'person_id' => $id, "joining_date" => $joiningDate, diff --git a/database/seeds/data/test/TestPersonTargetsTableSeeder.php b/database/seeds/data/test/TestPersonTargetsTableSeeder.php index eabcede..8493768 100644 --- a/database/seeds/data/test/TestPersonTargetsTableSeeder.php +++ b/database/seeds/data/test/TestPersonTargetsTableSeeder.php @@ -2,6 +2,8 @@ use Illuminate\Database\Seeder; +use App\Person; + class TestPersonTargetsTableSeeder extends Seeder { /** @@ -11,6 +13,10 @@ class TestPersonTargetsTableSeeder extends Seeder */ public function run() { - // + $people = Person::all(); + + for ($i = 0; $i < 300; $i++) { + $people->random()->targets()->save(factory(App\PersonTarget::class)->make()); + } } }