HouseCommentLikes.php 954 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: xiaofeng
  5. * Date: 2018/3/4
  6. * Time: 上午9:25
  7. */
  8. namespace common\models;
  9. class HouseCommentLikes extends Common
  10. {
  11. public function rules()
  12. {
  13. return [
  14. [['hid','hcid','ip'],'required','message'=>'{attribute}不能为空'],
  15. ['ip','ip'],
  16. [['del'],'in','range'=>[1,2],'message'=>'请输入正确的信息'],
  17. ];
  18. }
  19. public function Total()
  20. {
  21. return self::find()->andWhere(['del'=>1])->andFilterWhere(['hid'=>$this->hid])->andFilterWhere(['hcid'=>$this->hcid])->count();
  22. }
  23. public function FindById($id)
  24. {
  25. return self::findOne($id);
  26. }
  27. //Ip 限制
  28. public function Iplimit($input)
  29. {
  30. $total = self::find()->andWhere(['del'=>1,'hid'=>$input['hid'],'hcid'=>$input['hcid'],'ip'=>$input['ip']])->count();
  31. if($total >=1){
  32. return false;
  33. }
  34. return true;
  35. }
  36. }