deleteRelatedCalculatedScores(); }); static::updated(function ($bonusScore) { $bonusScore->deleteRelatedCalculatedScores(); }); static::deleted(function ($bonusScore) { $bonusScore->deleteRelatedCalculatedScores(); }); } public function entry(): BelongsTo { return $this->belongsTo(Entry::class); } public function judge(): BelongsTo { return $this->belongsTo(User::class, 'user_id'); } public function originallyScoredEntry(): BelongsTo { return $this->belongsTo(Entry::class, 'originally_scored_entry'); } public function deleteRelatedCalculatedScores(): void { $entry = $this->entry; if ($entry) { $entry->calculatedScores()->delete(); Cache::forget('entryScore-'.$entry->id.'-seating'); Cache::forget('entryScore-'.$entry->id.'-advancement'); Cache::forget('audition'.$entry->audition_id.'seating'); Cache::forget('audition'.$entry->audition_id.'advancement'); } } }