截流自动化的商城平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CommunityTopic.php 798B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace app\common\model\community;
  3. use app\common\basics\Models;
  4. /**
  5. * 种草社区话题
  6. * Class CommunityCategory
  7. * @package app\common\model\content
  8. */
  9. class CommunityTopic extends Models
  10. {
  11. /**
  12. * @notes 关联分类
  13. * @return \think\model\relation\HasOne
  14. * @author 段誉
  15. * @date 2022/4/28 14:18
  16. */
  17. public function cate()
  18. {
  19. return $this->hasOne(CommunityCategory::class, 'id', 'cid');
  20. }
  21. /**
  22. * @notes 扣减文章数量
  23. * @param $id
  24. * @return mixed
  25. * @author 段誉
  26. * @date 2022/5/10 16:43
  27. */
  28. public static function decArticleNum($id)
  29. {
  30. return self::where([
  31. ['id', '=', $id],
  32. ['article_num', '>=', 1]
  33. ])->dec('article_num')->update();
  34. }
  35. }