Update seeders
This commit is contained in:
parent
6ab624146c
commit
c6eb511146
|
|
@ -11,6 +11,8 @@ use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
||||||
class Room extends Model
|
class Room extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
protected $guarded = [];
|
||||||
|
//TODO can a user add rooms?
|
||||||
|
|
||||||
public function auditions(): HasMany
|
public function auditions(): HasMany
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ return new class extends Migration
|
||||||
{
|
{
|
||||||
Schema::table('auditions', function (Blueprint $table) {
|
Schema::table('auditions', function (Blueprint $table) {
|
||||||
$table->foreignIdFor(Room::class)->nullable()->constrained()->cascadeOnUpdate()->nullOnDelete();
|
$table->foreignIdFor(Room::class)->nullable()->constrained()->cascadeOnUpdate()->nullOnDelete();
|
||||||
$table->integer('order_in_room');
|
$table->integer('order_in_room')->default(0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ class AuditionSeeder extends Seeder
|
||||||
* Run the database seeds.
|
* Run the database seeds.
|
||||||
*/
|
*/
|
||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{ //TODO: Seed scoring guides for the auditions - Probably need percussion and wind
|
||||||
$event = Event::factory()->create([
|
$event = Event::factory()->create([
|
||||||
'name' => 'Concert Band Auditions'
|
'name' => 'Concert Band Auditions'
|
||||||
]);
|
]);
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ use App\Models\Entry;
|
||||||
use App\Models\Student;
|
use App\Models\Student;
|
||||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
|
use function mt_rand;
|
||||||
use function rand;
|
use function rand;
|
||||||
use function random_int;
|
use function random_int;
|
||||||
|
|
||||||
|
|
@ -35,7 +36,7 @@ class EntrySeeder extends Seeder
|
||||||
'audition_id' => $audition->id
|
'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','=','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 == 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 == 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','=','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 == 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 == 8) $audition3 = Audition::where('maximum_grade','=','9')->where('id','!=',$audition->id)->where('id','!=',$audition2->id)->inRandomOrder()->first();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue