<?php

namespace App\Models;

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

class Canton extends Model
{
    protected $table = 'tbl_cantons';

    protected $primaryKey = 'id_canton';

    public $incrementing = true;

    protected $keyType = 'int';

    protected $fillable = [
        'province_id',
        'name',
    ];

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

    public function province(): BelongsTo
    {
        return $this->belongsTo(Province::class, 'province_id', 'id_province');
    }

    public function districts(): HasMany
    {
        return $this->hasMany(District::class, 'canton_id', 'id_canton');
    }
}
