<?php

namespace Modules\Warehouse\Models;

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

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

    protected $fillable = [
        'latitude',
        'longitude',
        'phone',
        'postal_number',
        'upgrade_warehouse',
        'store_id',
        'warehouse_category_id',
        'warehouse_id',
        'country_id',
        'region_id',
        'city_id',
        'area_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 warehouseCategory()
    {
        return $this->belongsTo(WarehouseCategory::class)->withTrashed();
    }
    public function store()
    {
        return $this->belongsTo(Store::class)->withTrashed();
    }
}
