diff --git a/app/Http/Controllers/Tabulation/TabulationController.php b/app/Http/Controllers/Tabulation/TabulationController.php index 7cf7cbd..e27924c 100644 --- a/app/Http/Controllers/Tabulation/TabulationController.php +++ b/app/Http/Controllers/Tabulation/TabulationController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Tabulation; use App\Http\Controllers\Controller; use App\Models\Audition; use App\Services\DoublerService; +use App\Services\SeatingService; use App\Services\TabulationService; use function compact; @@ -12,13 +13,14 @@ use function compact; class TabulationController extends Controller { protected $tabulationService; - protected $doublerService; + protected $seatingService; - public function __construct(TabulationService $tabulationService, DoublerService $doublerService) + public function __construct(TabulationService $tabulationService, DoublerService $doublerService, SeatingService $seatingService) { $this->tabulationService = $tabulationService; $this->doublerService = $doublerService; + $this->seatingService = $seatingService; } public function status() @@ -45,10 +47,12 @@ class TabulationController extends Controller } } - $complete = $entries->every(function ($entry) { + $scoringComplete = $entries->every(function ($entry) { return $entry->scoring_complete; }); + $ensembleLimits = $this->seatingService->getLimitForAudition($audition->id); + $auditionComplete = $scoringComplete && $doublerComplete; - return view('tabulation.auditionSeating', compact('audition', 'entries', 'complete', 'doublerComplete')); + return view('tabulation.auditionSeating', compact('audition', 'entries', 'scoringComplete', 'doublerComplete', 'auditionComplete', 'ensembleLimits')); } } diff --git a/app/Models/Audition.php b/app/Models/Audition.php index b694787..4e873da 100644 --- a/app/Models/Audition.php +++ b/app/Models/Audition.php @@ -2,26 +2,27 @@ namespace App\Models; -use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\HasMany; -use Illuminate\Database\Eloquent\Relations\HasOne; -use phpDocumentor\Reflection\Types\Boolean; -use PhpParser\Node\Scalar\String_; + use function now; class Audition extends Model { use HasFactory; - protected $guarded = []; - protected $rankedEntries = null; - protected static $completeAuditions = null; - protected $fully_scored; // Set by TabulationService - protected $scored_entries_count; //Set by TabulationService + protected $guarded = []; + + protected $rankedEntries = null; + + protected static $completeAuditions = null; + + protected $fully_scored; // Set by TabulationService + + protected $scored_entries_count; //Set by TabulationService public static function deadlineNotPast() { @@ -38,7 +39,6 @@ class Audition extends Model return $this->hasMany(Entry::class); } - public function room(): BelongsTo { return $this->belongsTo(Room::class); @@ -49,9 +49,9 @@ class Audition extends Model return $this->belongsTo(ScoringGuide::class); } - public function dislpay_fee(): String + public function dislpay_fee(): string { - return '$' . number_format($this->entry_fee / 100, 2); + return '$'.number_format($this->entry_fee / 100, 2); } public function has_no_draw(): bool @@ -82,7 +82,7 @@ class Audition extends Model } if ($this->relationLoaded('entries')) { return $this->entries->every(function ($entry) { - return !is_null($entry->draw_number); + return ! is_null($entry->draw_number); }); } else { return $this->entries()->whereNull('draw_number')->doesntExist(); @@ -107,13 +107,14 @@ class Audition extends Model }); $hasNotNull = $this->entries->contains(function ($entry) { - return !is_null($entry->draw_number); + return ! is_null($entry->draw_number); }); return $hasNull && $hasNotNull; } else { $hasNull = $this->entries()->whereNull('draw_number')->exists(); $hasNotNull = $this->entries()->whereNotNull('draw_number')->exists(); + return $hasNull && $hasNotNull; } } @@ -126,6 +127,7 @@ class Audition extends Model $entry->update(['draw_number' => $index + 1]); $entry->save(); } + return null; // TODO move all draw functions to a DrawService } @@ -133,7 +135,7 @@ class Audition extends Model /** * @return BelongsToMany|\App\Models\User[] */ - public function judges() + public function judges(): array|BelongsToMany { return $this->belongsToMany( User::class, // The related model @@ -150,10 +152,10 @@ class Audition extends Model */ public function getJudgesCountAttribute() { - if (!isset($this->attributes['judges_count'])) { + if (! isset($this->attributes['judges_count'])) { $this->attributes['judges_count'] = $this->judges()->count(); } + return $this->attributes['judges_count']; } - } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 11fb104..1a4cbf7 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -54,23 +54,23 @@ class AppServiceProvider extends ServiceProvider return new SeatingService(); }); - $this->app->singleton(EntryCacheService::class, function($app) { + $this->app->singleton(EntryCacheService::class, function ($app) { return new EntryCacheService($app->make(AuditionCacheService::class)); }); - $this->app->singleton(ScoreService::class, function($app) { + $this->app->singleton(ScoreService::class, function ($app) { return new ScoreService($app->make(AuditionCacheService::class), $app->make(EntryCacheService::class)); }); - $this->app->singleton(TabulationService::class, function($app) { + $this->app->singleton(TabulationService::class, function ($app) { return new TabulationService( $app->make(AuditionCacheService::class), $app->make(ScoreService::class), $app->make(EntryCacheService::class)); }); - $this->app->singleton(DoublerService::class, function($app) { - return new DoublerService($app->make(AuditionCacheService::class),$app->make(TabulationService::class),$app->make(SeatingService::class)); + $this->app->singleton(DoublerService::class, function ($app) { + return new DoublerService($app->make(AuditionCacheService::class), $app->make(TabulationService::class), $app->make(SeatingService::class)); }); } @@ -91,7 +91,6 @@ class AppServiceProvider extends ServiceProvider SubscoreDefinition::observe(SubscoreDefinitionObserver::class); User::observe(UserObserver::class); - Event::listen( AuditionChange::class, RefreshAuditionCache::class diff --git a/resources/views/tabulation/auditionSeating.blade.php b/resources/views/tabulation/auditionSeating.blade.php index 7cb75b9..2091d8b 100644 --- a/resources/views/tabulation/auditionSeating.blade.php +++ b/resources/views/tabulation/auditionSeating.blade.php @@ -1,5 +1,7 @@ @inject('doublerService','App\Services\DoublerService') -@php($blockSeating = []) +@php + $blockSeating = [] +@endphp Audition Seating - {{ $audition->name }}
@@ -8,20 +10,43 @@ @include('tabulation.audition-results-table')
- - - Seating Form - -
- @if(! $complete) - Unable to seat. Not all entries are scored.
+ @if(! $auditionComplete) + + Unable to seat this audition + @if(! $scoringComplete) +

The audition cannot be seated while it has unscored entries.

@endif @if(! $doublerComplete) - Unable to seat. Not all doublers are resolved.
+

The audition cannot be seated while it has unresolved doublers.

@endif -
-
+ + @endif + + @if($auditionComplete) + @php + $entriesToSeat = $entries->reject(function ($entry) { + return $entry->hasFlag('declined'); + }); + @endphp + @foreach($ensembleLimits as $ensembleLimit) + + {{ $ensembleLimit->ensemble->name }} + + @for($n=1; $n <= $ensembleLimit->maximum_accepted; $n++) + @php + $entry = $entriesToSeat->shift(); + if (is_null($entry)) continue; + @endphp + + + {{ $n }} - {{ $entry->student->full_name() }} + + @endfor + + + @endforeach + @endif