quanwei
2026-01-17 e1e2fe5710a5b5cd9c19bd3aa99c998a1a613ca8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
 
namespace app\common\model\plus\live;
 
use app\common\model\BaseModel;
 
/**
 * 房间用户礼物模型
 */
class UserGift extends BaseModel
{
    protected $name = 'live_user_gift';
    protected $pk = 'user_gift_id';
 
    /**
     * 关联用户
     */
    public function user()
    {
        return $this->belongsTo('app\\common\\model\\user\\User', 'user_id', 'user_id')
            ->field(['user_id', 'nickName', 'avatarUrl']);
    }
 
    /**
     * 详情
     */
    public static function detail($room_id, $user_id)
    {
        return (new static())->where('room_id', '=', $room_id)
            ->where('user_id', '=', $user_id)
            ->find();
    }
 
    /**
     * 获取列表
     */
    public function getList($data)
    {
        return $this->with(['user'])
            ->where('room_id', '=', $data['room_id'])
            ->where('gift_num', '>', 0)
            ->order(['gift_num' => 'desc'])
            ->paginate($data);
    }
}