LiveGift.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\admin\model\live;
  12. /**
  13. * 直播间礼物
  14. */
  15. use basic\ModelBasic;
  16. use traits\ModelTrait;
  17. use app\admin\model\system\SystemGroupData;
  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::order('sort ASC')->select();
  31. $data = count($data) ? $data->toArray() : [];
  32. foreach ($data as &$item) {
  33. $item['add_time'] = date('Y-m-d H:i:s',$item['add_time']);
  34. $item['live_gift_num'] = implode(',',json_decode($item['live_gift_num']));
  35. }
  36. $count = self::count();
  37. return compact('data','count');
  38. }
  39. /**
  40. * 单个礼物信息
  41. */
  42. public static function liveGiftOne($id)
  43. {
  44. $gift=self::where('id',$id)->find();
  45. if($gift) return $gift;
  46. else return [];
  47. }
  48. }