the browser-facing portion of osu!
at master 1.1 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\Builder; 11use Illuminate\Database\Eloquent\Relations\BelongsTo; 12 13/** 14 * @property \Carbon\Carbon|null $created_at 15 * @property \App\Models\Solo\Score $score 16 * @property \Carbon\Carbon|null $updated_at 17 */ 18class ScorePin extends Model 19{ 20 public $incrementing = false; 21 22 protected $primaryKey = 'score_id'; 23 24 public function scopeForRuleset($query, string $ruleset): Builder 25 { 26 return $query->where('ruleset_id', Beatmap::MODES[$ruleset]); 27 } 28 29 public function scopeWithVisibleScore($query): Builder 30 { 31 return $query->whereHas('score', fn ($q) => $q->whereHas('beatmap.beatmapset')); 32 } 33 34 public function score(): BelongsTo 35 { 36 return $this->belongsTo(Solo\Score::class, 'score_id'); 37 } 38 39 public function user(): BelongsTo 40 { 41 return $this->belongsTo(User::class, 'user_id'); 42 } 43}