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

namespace common\models;

class HouseCommentLikes extends Common
{
    public function rules()
    {
        return [
            [['hid','hcid','ip'],'required','message'=>'{attribute}不能为空'],
            ['ip','ip'],
            [['del'],'in','range'=>[1,2],'message'=>'请输入正确的信息'],
        ];
    }

    public function Total()
    {
        return self::find()->andWhere(['del'=>1])->andFilterWhere(['hid'=>$this->hid])->andFilterWhere(['hcid'=>$this->hcid])->count();
    }


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

    //Ip 限制
    public function Iplimit($input)
    {
       $total =  self::find()->andWhere(['del'=>1,'hid'=>$input['hid'],'hcid'=>$input['hcid'],'ip'=>$input['ip']])->count();
       if($total >=1){
            return false;
       }
            return true;
    }

}