<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Concerns\HasUuids;

class Province extends Model
{
    use HasFactory, HasUuids;

    protected $table = 'provinces';

    const CREATED_AT = 'createDateTime';
    const UPDATED_AT = 'updateDateTime';

    protected $primaryKey = 'id';
    public $incrementing = false;
    protected $keyType = 'string';

    protected $fillable = [
        'countryId',
        'nameFa',
        'nameEn',
        'isActive'
    ];

    protected $casts = [
        'isActive' => 'boolean',
        'createDateTime' => 'datetime',
        'updateDateTime' => 'datetime'
    ];

    public function country()
    {
        return $this->belongsTo(Country::class, 'countryId', 'id');
    }

    public function cities()
    {
        return $this->hasMany(City::class, 'provinceId', 'id');
    }
}
