35 lines
1.2 KiB
PHP
35 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use App\Actions\Tabulation\EnterScore;
|
|
use App\Models\User;
|
|
use Illuminate\Database\Seeder;
|
|
|
|
class ScoreAllAuditions extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*/
|
|
public function run(): void
|
|
{
|
|
$recorder = app(EnterScore::class);
|
|
$judges = User::all();
|
|
foreach ($judges as $judge) { // Iterate over all users
|
|
foreach ($judge->rooms as $room) { // Iterate over each user's assigned rooms
|
|
foreach ($room->auditions as $audition) { // Iterate over each audition in that room
|
|
$scoringGuide = $audition->scoringGuide; // Load the scoring guide for that audition
|
|
$subscores = $scoringGuide->subscores; // Get the subscores for that audition
|
|
foreach ($audition->entries as $entry) { // Iterate over each entry in that audition
|
|
$scoreArray = [];
|
|
foreach ($subscores as $subscore) {
|
|
$scoreArray[$subscore->id] = mt_rand(0, $subscore->max_score);
|
|
}
|
|
$recorder($judge, $entry, $scoreArray);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|