Define Entry and EntryTotalScore relationships

This commit is contained in:
Matt Young 2025-06-12 08:47:04 -05:00
parent e79e7e222d
commit 8647a66df8
2 changed files with 12 additions and 14 deletions

View File

@ -17,16 +17,13 @@ class Entry extends Model
protected $guarded = []; protected $guarded = [];
protected $hasCheckedScoreSheets = false;
public $final_scores_array; // Set by TabulationService
public $scoring_complete; // Set by TabulationService
public $is_doubler; // Set by DoublerService
protected $with = ['flags']; protected $with = ['flags'];
public function totalScore(): HasOne
{
return $this->hasOne(EntryTotalScore::class);
}
public function student(): BelongsTo public function student(): BelongsTo
{ {
return $this->belongsTo(Student::class); return $this->belongsTo(Student::class);
@ -98,7 +95,7 @@ class Entry extends Model
public function removeFlag($flag): void public function removeFlag($flag): void
{ {
// remove related auditionFlag where flag_name = $flag // remove the related auditionFlag where flag_name = $flag
$this->flags()->where('flag_name', $flag)->delete(); $this->flags()->where('flag_name', $flag)->delete();
$this->load('flags'); $this->load('flags');
} }
@ -120,11 +117,6 @@ class Entry extends Model
return $this->hasOne(Seat::class); return $this->hasOne(Seat::class);
} }
public function calculatedScores(): HasMany
{
return $this->hasMany(CalculatedScore::class);
}
public function scopeForSeating(Builder $query): void public function scopeForSeating(Builder $query): void
{ {
$query->where('for_seating', 1); $query->where('for_seating', 1);

View File

@ -4,6 +4,7 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class EntryTotalScore extends Model class EntryTotalScore extends Model
{ {
@ -13,4 +14,9 @@ class EntryTotalScore extends Model
'seating_subscore_totals' => 'json', 'seating_subscore_totals' => 'json',
'advancement_subscore_totals' => 'json', 'advancement_subscore_totals' => 'json',
]; ];
public function entry(): BelongsTo
{
return $this->belongsTo(Entry::class);
}
} }