<?php

namespace App\Models;

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

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

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

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

    public function servers(): HasMany
    {
        return $this->hasMany(GameServer::class);
    }

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