<?php

namespace App\Models;

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

class GameServer extends Model
{
    protected $fillable = [
        'game_id',
        'game_region_id',
        'name',
        'sort_order',
    ];

    protected function casts(): array
    {
        return [
            'sort_order' => 'integer',
        ];
    }

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

    public function region(): BelongsTo
    {
        return $this->belongsTo(GameRegion::class, 'game_region_id');
    }

    public function playerGameProfiles(): HasMany
    {
        return $this->hasMany(PlayerGameProfile::class, 'server_id');
    }
}
