EntrySeeder format cleanup.
This commit is contained in:
parent
6c51d134de
commit
4fe4ea56d1
|
|
@ -5,11 +5,9 @@ namespace Database\Seeders;
|
||||||
use App\Models\Audition;
|
use App\Models\Audition;
|
||||||
use App\Models\Entry;
|
use App\Models\Entry;
|
||||||
use App\Models\Student;
|
use App\Models\Student;
|
||||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
use function mt_rand;
|
use function mt_rand;
|
||||||
use function rand;
|
|
||||||
use function random_int;
|
|
||||||
|
|
||||||
class EntrySeeder extends Seeder
|
class EntrySeeder extends Seeder
|
||||||
{
|
{
|
||||||
|
|
@ -24,39 +22,70 @@ class EntrySeeder extends Seeder
|
||||||
$jh_auditions = Audition::where('maximum_grade', '=', '9');
|
$jh_auditions = Audition::where('maximum_grade', '=', '9');
|
||||||
$seventh_auditions = Audition::where('maximum_grade', '=', '7');
|
$seventh_auditions = Audition::where('maximum_grade', '=', '7');
|
||||||
|
|
||||||
|
|
||||||
foreach ($students as $student) {
|
foreach ($students as $student) {
|
||||||
if($student->grade > 9) $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', '=', '12')->inRandomOrder()->first();
|
||||||
if($student->grade == 8) $audition = Audition::where('maximum_grade','=','9')->inRandomOrder()->first();
|
}
|
||||||
if($student->grade == 7) $audition = Audition::where('maximum_grade','=','7')->inRandomOrder()->first();
|
if ($student->grade == 9) {
|
||||||
|
$audition = Audition::where('maximum_grade', '>', '8')->inRandomOrder()->first();
|
||||||
|
}
|
||||||
|
if ($student->grade == 8) {
|
||||||
|
$audition = Audition::where('maximum_grade', '=', '9')->inRandomOrder()->first();
|
||||||
|
}
|
||||||
|
if ($student->grade == 7) {
|
||||||
|
$audition = Audition::where('maximum_grade', '=', '7')->inRandomOrder()->first();
|
||||||
|
}
|
||||||
|
|
||||||
Entry::factory()->create([
|
Entry::factory()->create([
|
||||||
'student_id' => $student->id,
|
'student_id' => $student->id,
|
||||||
'audition_id' => $audition->id
|
'audition_id' => $audition->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (mt_rand(1, 100) > 90) {
|
if (mt_rand(1, 100) > 90) {
|
||||||
if($student->grade > 9) $audition2 = Audition::where('maximum_grade','=','12')->where('id','!=',$audition->id)->inRandomOrder()->first();
|
if ($student->grade > 9) {
|
||||||
if($student->grade == 9) $audition2 = Audition::where('maximum_grade','>','8')->where('id','!=',$audition->id)->inRandomOrder()->first();
|
$audition2 = Audition::where('maximum_grade', '=', '12')->where('id', '!=',
|
||||||
if($student->grade == 8) $audition2 = Audition::where('maximum_grade','=','9')->where('id','!=',$audition->id)->inRandomOrder()->first();
|
$audition->id)->inRandomOrder()->first();
|
||||||
if($student->grade == 7) $audition2 = Audition::where('maximum_grade','=','7')->where('id','!=',$audition->id)->inRandomOrder()->first();
|
}
|
||||||
|
if ($student->grade == 9) {
|
||||||
|
$audition2 = Audition::where('maximum_grade', '>', '8')->where('id', '!=',
|
||||||
|
$audition->id)->inRandomOrder()->first();
|
||||||
|
}
|
||||||
|
if ($student->grade == 8) {
|
||||||
|
$audition2 = Audition::where('maximum_grade', '=', '9')->where('id', '!=',
|
||||||
|
$audition->id)->inRandomOrder()->first();
|
||||||
|
}
|
||||||
|
if ($student->grade == 7) {
|
||||||
|
$audition2 = Audition::where('maximum_grade', '=', '7')->where('id', '!=',
|
||||||
|
$audition->id)->inRandomOrder()->first();
|
||||||
|
}
|
||||||
|
|
||||||
Entry::factory()->create([
|
Entry::factory()->create([
|
||||||
'student_id' => $student->id,
|
'student_id' => $student->id,
|
||||||
'audition_id' => $audition2->id
|
'audition_id' => $audition2->id,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mt_rand(1, 100) > 90) {
|
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) {
|
||||||
if($student->grade == 9) $audition3 = Audition::where('maximum_grade','>','8')->where('id','!=',$audition->id)->where('id','!=',$audition2->id)->inRandomOrder()->first();
|
$audition3 = Audition::where('maximum_grade', '=', '12')->where('id', '!=',
|
||||||
if($student->grade == 8) $audition3 = Audition::where('maximum_grade','=','9')->where('id','!=',$audition->id)->where('id','!=',$audition2->id)->inRandomOrder()->first();
|
$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();
|
}
|
||||||
|
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([
|
Entry::factory()->create([
|
||||||
'student_id' => $student->id,
|
'student_id' => $student->id,
|
||||||
'audition_id' => $audition3->id
|
'audition_id' => $audition3->id,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue