44 lines
1.3 KiB
PHP
44 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Observers;
|
|
|
|
use App\Actions\Tabulation\TotalEntryScores;
|
|
use App\Models\ScoreSheet;
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
class ScoreSheetObserver
|
|
{
|
|
/**
|
|
* Handle the ScoreSheet "created" event.
|
|
*/
|
|
public function created(ScoreSheet $scoreSheet): void
|
|
{
|
|
$calculator = app(TotalEntryScores::class);
|
|
$calculator($scoreSheet->entry, true);
|
|
Cache::forget('rank_advancement_'.$scoreSheet->entry->audition_id);
|
|
Cache::forget('rank_seating_'.$scoreSheet->entry->audition_id);
|
|
}
|
|
|
|
/**
|
|
* Handle the ScoreSheet "updated" event.
|
|
*/
|
|
public function updated(ScoreSheet $scoreSheet): void
|
|
{
|
|
$calculator = app(TotalEntryScores::class);
|
|
$calculator($scoreSheet->entry, true);
|
|
Cache::forget('rank_advancement_'.$scoreSheet->entry->audition_id);
|
|
Cache::forget('rank_seating_'.$scoreSheet->entry->audition_id);
|
|
}
|
|
|
|
/**
|
|
* Handle the ScoreSheet "deleted" event.
|
|
*/
|
|
public function deleted(ScoreSheet $scoreSheet): void
|
|
{
|
|
$calculator = app(TotalEntryScores::class);
|
|
$calculator($scoreSheet->entry, true);
|
|
Cache::forget('rank_advancement_'.$scoreSheet->entry->audition_id);
|
|
Cache::forget('rank_seating_'.$scoreSheet->entry->audition_id);
|
|
}
|
|
}
|