68 lines
1.8 KiB
PHP
68 lines
1.8 KiB
PHP
<?php
|
||
|
||
namespace addons\webman\model;
|
||
|
||
use addons\webman\traits\DataPermissions;
|
||
use addons\webman\traits\HasDateTimeFormatter;
|
||
use DateTimeInterface;
|
||
use Illuminate\Database\Eloquent\Model;
|
||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||
|
||
/**
|
||
* Class SignIns
|
||
* @property int id 主键
|
||
* @property int player_id 玩家id
|
||
* @property int department_id 渠道id
|
||
* @property string sign_date 签到日期
|
||
* @property float reward_amount 奖励金额
|
||
* @property float chip_amount 打码量
|
||
* @property string created_at 创建时间
|
||
* @property string updated_at 最后一次修改时间
|
||
*
|
||
* @property Player player 玩家
|
||
* @property Channel channel 渠道
|
||
* @package addons\webman\model
|
||
*/
|
||
class SignIns extends Model
|
||
{
|
||
use HasDateTimeFormatter, DataPermissions;
|
||
|
||
//数据权限字段
|
||
protected $dataAuth = ['department_id' => 'department_id'];
|
||
//简写省略id,默认后台用户表的id
|
||
|
||
public function __construct(array $attributes = [])
|
||
{
|
||
parent::__construct($attributes);
|
||
$this->setTable(plugin()->webman->config('database.sign_ins_table'));
|
||
}
|
||
|
||
/**
|
||
* 渠道信息
|
||
* @return BelongsTo
|
||
*/
|
||
public function channel(): BelongsTo
|
||
{
|
||
return $this->belongsTo(plugin()->webman->config('database.channel_model'), 'department_id', 'department_id')->withTrashed();
|
||
}
|
||
|
||
/**
|
||
* 玩家信息
|
||
* @return BelongsTo
|
||
*/
|
||
public function player(): BelongsTo
|
||
{
|
||
return $this->belongsTo(plugin()->webman->config('database.player_model'), 'player_id');
|
||
}
|
||
|
||
/**
|
||
* 时间转换
|
||
* @param DateTimeInterface $date
|
||
* @return string
|
||
*/
|
||
protected function serializeDate(DateTimeInterface $date): string
|
||
{
|
||
return $date->format('Y-m-d H:i:s');
|
||
}
|
||
}
|