quanwei
2025-12-04 12913c1069347ea4b1f6ab87f480da0f8d8c646a
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
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
 
namespace app\common\model\plus\lottery;
 
use app\common\model\BaseModel;
 
/**
 * Class GiftPackage
 * 转盘模型
 * @package
 */
class Lottery extends BaseModel
{
    protected $name = 'lottery';
    protected $pk = 'lottery_id';
    /**
     * 追加字段
     * @var string[]
     */
    protected $append = ['status_text'];
 
    /**
     * 转盘详情
     */
    public static function detail()
    {
        return (new static())->with(['image'])->find();
    }
 
    /**
     * 状态
     */
    public function getStatusTextAttr($value, $data)
    {
        $text = '';
        if ($value == 1) {
            $text = '开启';
        } else {
            $text = '关闭';
        }
        return $text;
    }
    /**
     * 关联奖项
     */
    public function prize()
    {
        return $this->hasMany('app\\common\\model\\plus\\lottery\\LotteryPrize', 'lottery_id', 'lottery_id');
    }
    /**
     * 关联文件库
     */
    public function image()
    {
        return $this->belongsTo('app\\common\\model\\file\\UploadFile', 'image_id', 'file_id')
            ->bind(['file_path']);
    }
}