Work on Audition seeder
This commit is contained in:
parent
acb2d64179
commit
33747e0658
|
|
@ -17,7 +17,7 @@ class EventFactory extends Factory
|
||||||
public function definition(): array
|
public function definition(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
//
|
'name' => 'Concert Band Auditions'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ return new class extends Migration
|
||||||
{
|
{
|
||||||
Schema::create('events', function (Blueprint $table) {
|
Schema::create('events', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->string('name');
|
$table->string('name')->unique();
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,12 @@ return new class extends Migration
|
||||||
Schema::create('auditions', function (Blueprint $table) {
|
Schema::create('auditions', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->foreignIdFor(Event::class)->constrained()->cascadeOnUpdate()->restrictOnDelete();
|
$table->foreignIdFor(Event::class)->constrained()->cascadeOnUpdate()->restrictOnDelete();
|
||||||
$table->string('name');
|
$table->string('name')->unique();
|
||||||
$table->integer('order')->nullable()->unique();
|
$table->integer('order')->nullable()->unique();
|
||||||
$table->date(('entry_deadline'));
|
$table->date(('entry_deadline'));
|
||||||
$table->integer('entry_fee');
|
$table->integer('entry_fee');
|
||||||
|
$table->integer('minimum_grade');
|
||||||
|
$table->integer('maximum_grade');
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,67 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Models\Event;
|
||||||
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class AuditionSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
$event = Event::factory()->create([
|
||||||
|
'name' => 'Concert Band Auditions'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$instruments = [
|
||||||
|
'Flute',
|
||||||
|
'Oboe',
|
||||||
|
'Clarinet',
|
||||||
|
'Bass Clarinet',
|
||||||
|
'Contra Clarinet',
|
||||||
|
'Bassoon',
|
||||||
|
'Alto Sax',
|
||||||
|
'Tenor Sax',
|
||||||
|
'Bari Sax',
|
||||||
|
'Trumpet',
|
||||||
|
'Horn',
|
||||||
|
'Trombone',
|
||||||
|
'Euphonium',
|
||||||
|
'Tuba',
|
||||||
|
'String Bass',
|
||||||
|
'Percussion'
|
||||||
|
];
|
||||||
|
$levels = ['HS', 'JH', '7th'];
|
||||||
|
$n = 1;
|
||||||
|
foreach ($levels as $level) {
|
||||||
|
if ($level == 'HS') {
|
||||||
|
$minGrade = 9;
|
||||||
|
$maxGrade = 12;
|
||||||
|
}
|
||||||
|
if ($level == 'JH') {
|
||||||
|
$minGrade = 8;
|
||||||
|
$maxGrade = 9;
|
||||||
|
}if ($level == '7th') {
|
||||||
|
$minGrade = 7;
|
||||||
|
$maxGrade = 7;
|
||||||
|
}
|
||||||
|
foreach ($instruments as $instrument) {
|
||||||
|
DB::table('auditions')->insert([
|
||||||
|
'event_id' => $event->id,
|
||||||
|
'name' => $level . ' ' . $instrument,
|
||||||
|
'order' => $n,
|
||||||
|
'entry_deadline' => '2040-12-31',
|
||||||
|
'entry_fee' => '1000',
|
||||||
|
'minimum_grade' => $minGrade,
|
||||||
|
'maximum_grade' => $maxGrade
|
||||||
|
]);
|
||||||
|
$n++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue