the browser-facing portion of osu!
at master 47 lines 1.3 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\Relations\BelongsTo; 11 12/** 13 * @property int $count 14 * @property Country $country 15 * @property string $country_acronym 16 * @property User $user 17 * @property int $user_id 18 * @property \Carbon\Carbon $last_updated 19 * @property string $year_month 20 */ 21class UserCountryHistory extends Model 22{ 23 public $incrementing = false; 24 public $timestamps = false; 25 26 protected $casts = ['last_updated' => 'datetime']; 27 protected $primaryKey = ':composite'; 28 protected $primaryKeys = ['user_id', 'year_month', 'country_acronym']; 29 protected $table = 'user_country_history'; 30 31 public function country(): BelongsTo 32 { 33 return $this->belongsTo(Country::class, 'country_acronym'); 34 } 35 36 public function user(): BelongsTo 37 { 38 return $this->belongsTo(User::class, 'user_id'); 39 } 40 41 public function setYearMonthAttribute(\DateTimeInterface|string $value): void 42 { 43 $this->attributes['year_month'] = $value instanceof \DateTimeInterface 44 ? format_month_column($value) 45 : $value; 46 } 47}