<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\SoftDeletes;

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

    protected $fillable = [
        'room_id','start_count','end_count','cost','status_min','min_count','external_image','internal_image','max_count'
    ];


    /**
     * Get current description of the the Room
     * @return HasOne
     */
    public function currentDescription() :HasOne
    {
        return $this->hasOne(RoomDescription::class)->where('language_id', currentLanguage()->id);
    }
    
    public function getroomMinCountAttribute()
    {
        if($this->min_count == 1)
        {
            $count = __('web.one_least_room');
        }
        elseif($this->min_count == 2)
        {
            $count = __('web.two_least_room');
        }
        else
        {
            $count = (getCurrentLocale() == 'en' ? __('web.min_room_person') .  $this->min_count . ' ' . __('web.person_room') : $this->min_count . ' ' . __('web.min_room_person') ) ;
        }
        return $count; 
    }
    
    public function getroomMaxCountAttribute()
    {
        if($this->max_count == 1)
        {
            $count = __('web.one_max_least_room');
        }
        elseif($this->max_count == 2)
        {
            $count = __('web.two_max_least_room');
        }
        else
        {
            $count = (getCurrentLocale() == 'en' ? __('web.max_room_person') .  $this->max_count . ' ' . __('web.person_room') : $this->max_count . ' ' . __('web.max_room_person') ) ;
        }
        return $count; 
    }
}
