CommentPraise.php 749 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace app\common\model;
  3. /**
  4. * 用户评价点赞模型
  5. * Class CommentPraise
  6. * @package app\common\model
  7. */
  8. class CommentPraise extends BaseModel
  9. {
  10. protected $name = 'comment_praise';
  11. public function addOne($data) {
  12. if (empty($data)) {
  13. return false;
  14. }
  15. $this->save($data);
  16. }
  17. public function deleteOne($data) {
  18. $this->where($data)->delete();
  19. }
  20. public static function checkPraise($user_id, $comment_id)
  21. {
  22. if (empty($user_id)) {
  23. return false;
  24. }
  25. $one = self::where('comment_id', $comment_id)->where('user_id', $user_id)->find();
  26. if (empty($one)) {
  27. return false;
  28. }
  29. return true;
  30. }
  31. }