the browser-facing portion of osu!
at master 1.2 kB view raw
1<?php 2 3// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0. 4// See the LICENCE file in the repository root for full licence text. 5 6declare(strict_types=1); 7 8namespace App\Models; 9 10use Illuminate\Database\Eloquent\Collection; 11use Illuminate\Database\Eloquent\Relations\BelongsTo; 12use Illuminate\Database\Eloquent\Relations\HasMany; 13 14/** 15 * @property-read Collection<ContestJudgeScore> $scores 16 * @property string|null $comment 17 * @property int $contest_entry_id 18 * @property \Carbon\Carbon|null $created_at 19 * @property-read ContestEntry $entry 20 * @property int $id 21 * @property \Carbon\Carbon|null $updated_at 22 * @property-read User $user 23 * @property int $user_id 24 */ 25class ContestJudgeVote extends Model 26{ 27 public function scores(): HasMany 28 { 29 return $this->hasMany(ContestJudgeScore::class); 30 } 31 32 public function entry(): BelongsTo 33 { 34 return $this->belongsTo(ContestEntry::class, 'contest_entry_id'); 35 } 36 37 public function totalScore(): int 38 { 39 return intval($this->scores()->sum('value')); 40 } 41 42 public function user(): BelongsTo 43 { 44 return $this->belongsTo(User::class, 'user_id'); 45 } 46}