<?php

namespace Modules\City\Models;

use Modules\City\Models\CityDescription;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\SoftDeletes;
use Modules\Country\Models\Country;
use Modules\Region\Models\Region;
use Modules\Area\Models\Area;

class City extends Model
{
    //use soft delete
    use SoftDeletes;

    protected $fillable = [
        'region_id'
    ];


    /**
     * Get current description of the the Room
     * @return HasOne
     */
    public function region()
    {
        return $this->belongsTo(Region::class)->withTrashed();
    }
    
    public function areas()
    {
        return $this->hasMany(Area::class);
    }

    public function currentDescription() :HasOne
    {
        return $this->hasOne(CityDescription::class)->where('language_id', currentLanguage()->id);
    }
}
