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
6namespace App\Models;
7
8use Illuminate\Database\Eloquent\Relations\BelongsTo;
9
10/**
11 * @property int $mode
12 * @property int $rank
13 * @property \Carbon\Carbon $updated_at
14 * @property-read string $updated_at_json
15 * @property-read User $user
16 * @property int $user_id
17 */
18class RankHighest extends Model
19{
20 public $incrementing = false;
21 public $timestamps = false;
22
23 protected $casts = ['updated_at' => 'datetime'];
24 protected $primaryKey = ':composite';
25 protected $primaryKeys = ['user_id', 'mode'];
26 protected $table = 'osu_user_performance_rank_highest';
27
28 public function user(): BelongsTo
29 {
30 return $this->belongsTo(User::class, 'user_id');
31 }
32
33 public function getAttribute($key)
34 {
35 return match ($key) {
36 'mode',
37 'rank',
38 'user_id' => $this->getRawAttribute($key),
39
40 'updated_at' => $this->getTimeFast($key),
41
42 'updated_at_json' => $this->getJsonTimeFast($key),
43
44 'user' => $this->getRelationValue($key),
45 };
46 }
47}