<?php
/**
 * Created by PhpStorm.
 * User: xiaofeng
 * Date: 2018/3/4
 * Time: 上午9:34
 */

namespace common\models;

use Yii;

class HouseDetail extends Common
{

    public function rules()
    {
        return [

            ['phone_sales', 'string', 'max' => '15'],
            ['main_units', 'string', 'max' => 80],
            ['longitude_latitude', 'string', 'max' => 50],
            ['info', 'string'],
//                ['evaluating','string'],
            ['price_unit', 'in', 'range' => Yii::$app->params['HousePriceUnit']],
            [['open_time', 'launch_time'], 'string', 'max' => 50],

            [['address', 'sales_address', 'land_agent', 'panorama'], 'string', 'max' => 100],
            ['house_cx', 'string', 'max' => 50],
            ['developers', 'string', 'max' => 50],
            [['property_company', 'property_costs', 'sale_permit'], 'string', 'max' => 50],
            ['preferential', 'string', 'max' => 100],
            ['planning_area', 'string', 'max' => 20],
            ['features', 'string', 'max' => 2000],
            ['parking_num', 'string', 'max' => 20],
            ['total_building', 'string', 'max' => 10],
            [['bus_route', 'floor_condition'], 'string', 'max' => 200],
            [['construction_area', 'planning_households'], 'string', 'max' => 50],
            [['volume_rate', 'greening_rate'], 'string', 'max' => 50],
            ['hot', 'in', 'range' => [1, 2]],
            ['property_tag', 'each', 'rule' => ['integer']],
//                ['fit','each','rule'=>['integer']]
            ['fit', 'in', 'range' => array_flip(Yii::$app->params['Housefit'])],
            ['panorama', 'default', 'value' => ''],
            [['push_reason', 'preferential_price', 'preferential_zt'], 'string'],
            ['video_url', 'string'],             ['video_img', 'string'],             ['panorama_img', 'string'],
        ];
    }


    public function attributeLabels()
    {
        return [
            'phone_sales' => '电话号码',
            'main_units' => '主力户型',
            'address' => '项目地址',
            'sales_address' => '售楼地址',
            'property_company' => '物业公司',
            'property_costs' => '物业费',
            'sale_permit' => '许可证号',
            'preferential' => '优惠信息',
            'planning_area' => '占地面积',
            'parking_num' => '车位数量',
            'volume_rate' => '容积率',
            'total_building' => '总栋数',
            'longitude_latitude' => '经纬度',
            'panorama' => 'VR全景看房',
            'greening_rate' => '绿化率',
            'house_cx' => '产权年限',
            'info' => '文章内容',
            'bus_route' => '公交路线',
            'construction_area' => '建筑面积',
            'planning_households' => '总户数',
            'floor_condition' => '楼层状况',
            'features' => '楼盘特点',
            'hot' => '热门楼盘',
            'property_tag' => '楼盘标签',
            'developers' => '开发商',
            'open_time' => '开盘时间',
            'launch_time' => '交房时间',
            'land_agent' => '投资商',
            'price_unit' => '价格单位',
            'fit' => '装修情况',
            'evaluating' => '楼盘评测',
        ];
    }


    public function Authenticator($input)
    {
        $this->load($input, '');
        if (!$this->validate()) return $this->errors;
        return $this;
    }

    public function FindById($id)
    {
        return self::findOne($id);
    }
}