60 lines
1.5 KiB
PHP
60 lines
1.5 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;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
/**
|
|
* Class PlayerPromoter
|
|
* @property int id 主键
|
|
* @property string batch_code 批次码
|
|
* @property int score 面值
|
|
* @property int batch_count 数量
|
|
* @property int owner_id 持码者
|
|
* @property string creator 创建人
|
|
* @property int brand_id
|
|
* @property int status 状态
|
|
* @property string created_at 创建时间
|
|
* @property string updated_at 修改时间
|
|
*
|
|
* @property QrcodeBatch qrcode_bath
|
|
* @package addons\webman\model
|
|
*/
|
|
class QrcodeBatch extends Model
|
|
{
|
|
use HasDateTimeFormatter, DataPermissions;
|
|
|
|
/**
|
|
* 时间转换
|
|
* @param DateTimeInterface $date
|
|
* @return string
|
|
*/
|
|
protected function serializeDate(DateTimeInterface $date): string
|
|
{
|
|
return $date->format('Y-m-d H:i:s');
|
|
}
|
|
|
|
public function __construct(array $attributes = [])
|
|
{
|
|
parent::__construct($attributes);
|
|
$this->setTable(plugin()->webman->config('database.qrcode_batch_table'));
|
|
}
|
|
|
|
|
|
public function qrcode_owner(): BelongsTo
|
|
{
|
|
return $this->belongsTo(plugin()->webman->config('database.qrcode_owner_model'), 'owner_id');
|
|
}
|
|
|
|
public function qrcode(): HasMany
|
|
{
|
|
return $this->hasMany(plugin()->webman->config('database.qrcode_model'), 'batch_id');
|
|
}
|
|
|
|
}
|