EntrySeeder update

This commit is contained in:
Matt Young 2025-06-10 23:35:21 -05:00
parent 551f04588c
commit bcaab84ded
1 changed files with 29 additions and 19 deletions

View File

@ -17,51 +17,59 @@ class EntrySeeder extends Seeder
public function run(): void public function run(): void
{ {
$students = Student::all(); $students = Student::all();
$hs_auditions = Audition::where('maximum_grade', '=', '12');
$freshman_auditions = Audition::where('maximum_grade', '>', '8');
$jh_auditions = Audition::where('maximum_grade', '=', '9');
$seventh_auditions = Audition::where('maximum_grade', '=', '7');
foreach ($students as $student) { foreach ($students as $student) {
if ($student->grade > 9) { if ($student->grade > 9) {
$audition = Audition::where('maximum_grade', '=', '12')->inRandomOrder()->first(); $audition = Audition::where('maximum_grade', '=', '12')
->inRandomOrder()->first();
} }
if ($student->grade == 9) { if ($student->grade == 9) {
$audition = Audition::where('maximum_grade', '>', '8')->inRandomOrder()->first(); $audition = Audition::where('maximum_grade', '>', '8')
->inRandomOrder()->first();
} }
if ($student->grade == 8) { if ($student->grade == 8) {
$audition = Audition::where('maximum_grade', '=', '9')->inRandomOrder()->first(); $audition = Audition::where('maximum_grade', '=', '9')
->inRandomOrder()->first();
} }
if ($student->grade == 7) { if ($student->grade == 7) {
$audition = Audition::where('maximum_grade', '=', '7')->inRandomOrder()->first(); $audition = Audition::where('maximum_grade', '=', '7')
->inRandomOrder()->first();
} }
Entry::factory()->create([ Entry::create([
'student_id' => $student->id, 'student_id' => $student->id,
'audition_id' => $audition->id, 'audition_id' => $audition->id,
'for_seating' => 1,
'for_advancement' => 1,
]); ]);
if (mt_rand(1, 100) > 90) { if (mt_rand(1, 100) > 90) {
if ($student->grade > 9) { if ($student->grade > 9) {
$audition2 = Audition::where('maximum_grade', '=', '12')->where('id', '!=', $audition2 = Audition::where('maximum_grade', '=', '12')
$audition->id)->inRandomOrder()->first(); ->where('id', '!=', $audition->id)
->inRandomOrder()->first();
} }
if ($student->grade == 9) { if ($student->grade == 9) {
$audition2 = Audition::where('maximum_grade', '>', '8')->where('id', '!=', $audition2 = Audition::where('maximum_grade', '>', '8')
$audition->id)->inRandomOrder()->first(); ->where('id', '!=', $audition->id)
->inRandomOrder()->first();
} }
if ($student->grade == 8) { if ($student->grade == 8) {
$audition2 = Audition::where('maximum_grade', '=', '9')->where('id', '!=', $audition2 = Audition::where('maximum_grade', '=', '9')
$audition->id)->inRandomOrder()->first(); ->where('id', '!=', $audition->id)
->inRandomOrder()->first();
} }
if ($student->grade == 7) { if ($student->grade == 7) {
$audition2 = Audition::where('maximum_grade', '=', '7')->where('id', '!=', $audition2 = Audition::where('maximum_grade', '=', '7')
$audition->id)->inRandomOrder()->first(); ->where('id', '!=', $audition->id)
->inRandomOrder()->first();
} }
Entry::factory()->create([ Entry::create([
'student_id' => $student->id, 'student_id' => $student->id,
'audition_id' => $audition2->id, 'audition_id' => $audition2->id,
'for_seating' => 1,
'for_advancement' => 1,
]); ]);
} }
@ -83,9 +91,11 @@ class EntrySeeder extends Seeder
$audition->id)->where('id', '!=', $audition2->id)->inRandomOrder()->first(); $audition->id)->where('id', '!=', $audition2->id)->inRandomOrder()->first();
} }
Entry::factory()->create([ Entry::create([
'student_id' => $student->id, 'student_id' => $student->id,
'audition_id' => $audition3->id, 'audition_id' => $audition3->id,
'for_seating' => 1,
'for_advancement' => 1,
]); ]);
} }
} }