Update EntrySeeder.php

Fix entry seeder
This commit is contained in:
Matt Young 2025-06-11 10:13:04 -05:00
parent 551f04588c
commit c2572414e6
1 changed files with 27 additions and 24 deletions

View File

@ -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,
]);
}
}
}
}