<?php

namespace Modules\Warehouse\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\SoftDeletes;
use Modules\City\Models\City;
use Modules\Country\Models\Country;
use Modules\Store\Models\Store;
use Modules\WarehouseCategory\Models\WarehouseCategory;

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

    protected $fillable = [
        'email',
        'phone',
        'country_id'
    ];


    /**
     * Get current description of the the Room
     * @return HasOne
     */
    public function currentDescription() :HasOne
    {
        return $this->hasOne(WarehouseDescription::class)->where('language_id', currentLanguage()->id);
    }

    public function country()
    {
        return $this->belongsTo(Country::class)->withTrashed();
    }

    public function cities()
    {
        return $this->belongsToMany(City::class,'warehouse_cities');
    }

}
