LearningRecords.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\wap\model\special;
  12. use basic\ModelBasic;
  13. use traits\ModelTrait;
  14. use think\Db;
  15. /**用户浏览记录 model
  16. * Class LearningRecords
  17. * @package app\wap\model\special
  18. */
  19. class LearningRecords extends ModelBasic
  20. {
  21. use ModelTrait;
  22. /**
  23. * 记录用户浏览记录
  24. * @param $specialId
  25. * @param $uid
  26. * @return false|int|object
  27. * @throws \think\db\exception\DataNotFoundException
  28. * @throws \think\db\exception\ModelNotFoundException
  29. * @throws \think\exception\DbException
  30. */
  31. public static function recordLearning($specialId, $uid, $time)
  32. {
  33. $info = self::where(['uid' => $uid, 'special_id' => $specialId, 'add_time' => $time])->find();
  34. $res = true;
  35. if (!$info) {
  36. $res = self::set([
  37. 'add_time' => $time,
  38. 'uid' => $uid,
  39. 'special_id' => $specialId
  40. ]);
  41. }
  42. return $res;
  43. }
  44. }