<?php

namespace App\Models;

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

class City extends Model
{
    use HasFactory, HasUuids;

    protected $table = 'cities';

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

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

    protected $fillable = [
        'provinceId',
        'nameFa',
        'nameEn',
        'lat',
        'lng',
        'level',
        'isActive'
    ];

    protected $casts = [
        'lat' => 'decimal:7',
        'lng' => 'decimal:7',
        'level' => 'integer',
        'isActive' => 'boolean',
        'createDateTime' => 'datetime',
        'updateDateTime' => 'datetime'
    ];

    public function province()
    {
        return $this->belongsTo(Province::class, 'provinceId', 'id');
    }

    public function weatherResults()
    {
        return $this->hasMany(WeatherResult::class, 'cityId', 'id');
    }
}
