HouseCommentreply.php 1001 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 HouseCommentreply extends Common
  10. {
  11. public function rules()
  12. {
  13. return [
  14. [['cid','reply_content'],'required','message'=>'{attribute}不能为空'],
  15. ['reply_content','string','max'=>200],
  16. ['label','in','range'=>[1,2]],
  17. ['label','integer','max'=>1],
  18. ];
  19. }
  20. public function attributeLabels()
  21. {
  22. return [
  23. 'cid'=>'点评',
  24. 'reply_content'=>'点评内容',
  25. 'label'=>'标签'
  26. ];
  27. }
  28. public function FindById($id)
  29. {
  30. return self::findOne($id);
  31. }
  32. public function getCommentReply($comment_id){
  33. $query = self::find();
  34. $row = $query->andWhere(['cid' => $comment_id])->orderBy(['create_at'=>SORT_DESC])->one();
  35. if(!empty($row)){
  36. return $row['reply_content'];
  37. }
  38. return null;
  39. }
  40. }