Update seeders

This commit is contained in:
Matt Young 2024-06-11 20:46:32 -05:00
parent 6ab624146c
commit c6eb511146
4 changed files with 7 additions and 4 deletions

View File

@ -11,6 +11,8 @@ use Illuminate\Database\Eloquent\Relations\HasManyThrough;
class Room extends Model
{
use HasFactory;
protected $guarded = [];
//TODO can a user add rooms?
public function auditions(): HasMany
{

View File

@ -14,7 +14,7 @@ return new class extends Migration
{
Schema::table('auditions', function (Blueprint $table) {
$table->foreignIdFor(Room::class)->nullable()->constrained()->cascadeOnUpdate()->nullOnDelete();
$table->integer('order_in_room');
$table->integer('order_in_room')->default(0);
});
}

View File

@ -13,7 +13,7 @@ class AuditionSeeder extends Seeder
* Run the database seeds.
*/
public function run(): void
{
{ //TODO: Seed scoring guides for the auditions - Probably need percussion and wind
$event = Event::factory()->create([
'name' => 'Concert Band Auditions'
]);

View File

@ -7,6 +7,7 @@ use App\Models\Entry;
use App\Models\Student;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use function mt_rand;
use function rand;
use function random_int;
@ -35,7 +36,7 @@ class EntrySeeder extends Seeder
'audition_id' => $audition->id
]);
if (random_int(1,100) > 80) {
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) $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();
@ -47,7 +48,7 @@ class EntrySeeder extends Seeder
]);
}
if (random_int(1,100) > 80) {
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();