<?php

namespace app\admin\model\hotel;

use think\Model;


class Room extends Model
{

    

    

    // 表名
    protected $name = 'room';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'room_type_text'
    ];
    

    
    public function getRoomTypeList()
    {
        return ['1' => __('Room_type 1'), '2' => __('Room_type 2'), '3' => __('Room_type 3'), '4' => __('Room_type 4')];
    }


    public function getRoomTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['room_type']) ? $data['room_type'] : '');
        $list = $this->getRoomTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function shop()
    {
        return $this->belongsTo('\app\admin\model\hotel\Hotel', 'shop_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }

    public function building()
    {
        return $this->belongsTo('\app\admin\model\hotel\Building', 'building_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }




}