<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class EloHistory extends Model
{
    protected $table = 'elo_history';

    protected $fillable = [
        'user_id', 'match_id', 'elo_before', 'elo_after', 'change',
    ];

    protected $casts = [
        'elo_before' => 'integer',
        'elo_after'  => 'integer',
        'change'     => 'integer',
    ];

    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }

    public function match(): BelongsTo
    {
        return $this->belongsTo(GameMatch::class, 'match_id');
    }
}
