LiveGift.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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\live;
  12. use basic\ModelBasic;
  13. use traits\ModelTrait;
  14. /**直播间礼物
  15. * Class LiveGift
  16. * @package app\wap\model\live
  17. */
  18. class LiveGift extends ModelBasic
  19. {
  20. use ModelTrait;
  21. /**礼物列表
  22. * @return array
  23. * @throws \think\Exception
  24. * @throws \think\db\exception\DataNotFoundException
  25. * @throws \think\db\exception\ModelNotFoundException
  26. * @throws \think\exception\DbException
  27. */
  28. public static function liveGiftList()
  29. {
  30. $data = self::where('is_show', 1)->order('sort DESC,id DESC')->select();
  31. $data = count($data) ? $data->toArray() : [];
  32. foreach ($data as &$item) {
  33. $item['live_gift_num'] = json_decode($item['live_gift_num']);
  34. }
  35. return $data;
  36. }
  37. /**
  38. * 单个礼物信息
  39. */
  40. public static function liveGiftOne($id)
  41. {
  42. $gift = self::where('is_show', 1)->where('id', $id)->find();
  43. if ($gift) return $gift;
  44. else return [];
  45. }
  46. }