<?php

namespace App\Modules\Platform\Geography\Models;

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

class GeoRegion extends Model
{
    protected $table = 'geo_regions';

    protected $fillable = [
        'country_id',
        'tenant_id',
        'name',
        'is_active',
        'sort_order',
    ];

    protected function casts(): array
    {
        return [
            'name' => 'array',
            'is_active' => 'boolean',
        ];
    }

    public function country(): BelongsTo
    {
        return $this->belongsTo(GeoCountry::class, 'country_id');
    }

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