Files
dafuweng/addons/webman/model/QrcodeOwner.php
2026-03-02 13:44:38 +08:00

59 lines
1.6 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\hasMany;
use Illuminate\Database\Eloquent\Relations\hasManyThrough;
/**
* 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 QrcodeOwner qrcode_owner
* @package addons\webman\model
*/
class QrcodeOwner 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_owner_table'));
}
public function qrcode_batch(): hasMany
{
return $this->hasMany(plugin()->webman->config('database.qrcode_batch_model'), 'owner_id');
}
public function qrcode(): hasManyThrough
{
return $this->hasManyThrough(plugin()->webman->config('database.qrcode_model'), plugin()->webman->config('database.qrcode_batch_model'), 'owner_id', 'batch_id');
}
}