<?php

namespace App\Modules\Pilkades\Models;

use App\Core\Concerns\HasUuid;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;

class Kecamatan extends Model
{
    use HasFactory, HasUuid, SoftDeletes;

    protected $table = 'kecamatan';

    protected $fillable = [
        'kabupaten_id',
        'nama',
        'slug',
        'kode_wilayah',
        'is_active',
    ];

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

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

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