ArticleCollect.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\common\model\article;
  15. use app\common\enum\YesNoEnum;
  16. use app\common\model\BaseModel;
  17. use think\model\concern\SoftDelete;
  18. /**
  19. * 资讯收藏
  20. * Class ArticleCollect
  21. * @package app\common\model\article
  22. */
  23. class ArticleCollect extends BaseModel
  24. {
  25. use SoftDelete;
  26. protected $deleteTime = 'delete_time';
  27. /**
  28. * @notes 是否已收藏文章
  29. * @param $userId
  30. * @param $articleId
  31. * @return bool (true=已收藏, false=未收藏)
  32. * @author 段誉
  33. * @date 2022/10/20 15:13
  34. */
  35. public static function isCollectArticle($userId, $articleId)
  36. {
  37. $collect = ArticleCollect::where([
  38. 'user_id' => $userId,
  39. 'article_id' => $articleId,
  40. 'status' => YesNoEnum::YES
  41. ])->findOrEmpty();
  42. return !$collect->isEmpty();
  43. }
  44. }