diff --git a/database/seeders/EntrySeeder.php b/database/seeders/EntrySeeder.php index 9d8334a..54e710d 100644 --- a/database/seeders/EntrySeeder.php +++ b/database/seeders/EntrySeeder.php @@ -36,7 +36,7 @@ class EntrySeeder extends Seeder $audition = Audition::where('maximum_grade', '=', '7')->inRandomOrder()->first(); } - Entry::factory()->create([ + Entry::create([ 'student_id' => $student->id, 'audition_id' => $audition->id, ]); @@ -59,35 +59,38 @@ class EntrySeeder extends Seeder $audition->id)->inRandomOrder()->first(); } - Entry::factory()->create([ + Entry::create([ 'student_id' => $student->id, 'audition_id' => $audition2->id, ]); + + // Triplers are possible + if (mt_rand(1, 100) > 90) { + if ($student->grade > 9) { + $audition3 = Audition::where('maximum_grade', '=', '12')->where('id', '!=', + $audition->id)->where('id', '!=', $audition2->id)->inRandomOrder()->first(); + } + if ($student->grade == 9) { + $audition3 = Audition::where('maximum_grade', '>', '8')->where('id', '!=', + $audition->id)->where('id', '!=', $audition2->id)->inRandomOrder()->first(); + } + if ($student->grade == 8) { + $audition3 = Audition::where('maximum_grade', '=', '9')->where('id', '!=', + $audition->id)->where('id', '!=', $audition2->id)->inRandomOrder()->first(); + } + if ($student->grade == 7) { + $audition3 = Audition::where('maximum_grade', '=', '7')->where('id', '!=', + $audition->id)->where('id', '!=', $audition2->id)->inRandomOrder()->first(); + } + + Entry::create([ + 'student_id' => $student->id, + 'audition_id' => $audition3->id, + ]); + } } - if (mt_rand(1, 100) > 90) { - if ($student->grade > 9) { - $audition3 = Audition::where('maximum_grade', '=', '12')->where('id', '!=', - $audition->id)->where('id', '!=', $audition2->id)->inRandomOrder()->first(); - } - if ($student->grade == 9) { - $audition3 = Audition::where('maximum_grade', '>', '8')->where('id', '!=', - $audition->id)->where('id', '!=', $audition2->id)->inRandomOrder()->first(); - } - if ($student->grade == 8) { - $audition3 = Audition::where('maximum_grade', '=', '9')->where('id', '!=', - $audition->id)->where('id', '!=', $audition2->id)->inRandomOrder()->first(); - } - if ($student->grade == 7) { - $audition3 = Audition::where('maximum_grade', '=', '7')->where('id', '!=', - $audition->id)->where('id', '!=', $audition2->id)->inRandomOrder()->first(); - } - Entry::factory()->create([ - 'student_id' => $student->id, - 'audition_id' => $audition3->id, - ]); - } } } }