<?php

namespace addons\webman\model;

use addons\webman\traits\DataPermissions;
use addons\webman\traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

/**
 * Class Game
 * @property int id 主键
 * @property int department_id 渠道ID
 * @property int uid 玩家id
 * @property int prize_id 奖品id
 * @property int prize_type 奖品类型
 * @property string prize_name 奖品名称
 * @property string prize_pic 奖品图片
 * @property int game_id 游戏id
 * @property int game_type 游戏类型
 * @property string draw_time 抽奖时间
 * @property string ip 用户ip
 * @property float consume 抽奖消耗
 * @property string remove_status 是否标记
 * @property string created_at 创建时间
 * @property string updated_at 最后一次修改时间
 *
 * @property GamePlatform gamePlatform 游戏平台信息
 * @property Player player 玩家
 * @property Channel channel 渠道
 * @package addons\webman\model
 */

class DrawRecord extends Model
{
    use HasDateTimeFormatter, DataPermissions;
    //数据权限字段
    protected $dataAuth = ['department_id' => 'department_id'];
    protected $table = 'draw_records';
    public $timestamps = false;
    protected $fillable = ['uid', 'prize_id', 'prize_type', 'prize_name', 'prize_pic', 'game_id', 'game_type', 'department_id', 'draw_time', 'ip', 'consume'];

    /**
     * 奖品信息
     * @return BelongsTo
     */
    public function prize(): BelongsTo
    {
        return $this->belongsTo(plugin()->webman->config('database.prize_model'), 'prize_id', 'id');
    }

    /**
     * 玩家信息
     * @return BelongsTo
     */
    public function player(): BelongsTo
    {
        return $this->belongsTo(plugin()->webman->config('database.player_model'), 'uid')->withTrashed();
    }

    /**
     * 渠道信息
     * @return BelongsTo
     */
    public function channel(): BelongsTo
    {
        return $this->belongsTo(plugin()->webman->config('database.channel_model'), 'department_id', 'department_id')->withTrashed();
    }


}