feat: 添加新的错误码以支持配置版本管理,更新彩票配置以启用手动审核,增强 API 路由以支持玩法和赔率版本化管理
This commit is contained in:
55
app/Models/RiskCapVersion.php
Normal file
55
app/Models/RiskCapVersion.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Lottery\ConfigVersionStatus;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
/** {@see risk_cap_versions} */
|
||||
class RiskCapVersion extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'version_no',
|
||||
'status',
|
||||
'effective_at',
|
||||
'updated_by',
|
||||
'reason',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'version_no' => 'integer',
|
||||
'effective_at' => 'datetime',
|
||||
'updated_by' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::saving(function (RiskCapVersion $m): void {
|
||||
if ($m->status === null || $m->status === '') {
|
||||
$m->status = ConfigVersionStatus::Draft->value;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** @return BelongsTo<AdminUser, RiskCapVersion> */
|
||||
public function updatedByAdmin(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(AdminUser::class, 'updated_by');
|
||||
}
|
||||
|
||||
/** @return HasMany<RiskCapItem, RiskCapVersion> */
|
||||
public function items(): HasMany
|
||||
{
|
||||
return $this->hasMany(RiskCapItem::class, 'version_id');
|
||||
}
|
||||
|
||||
public function isDraft(): bool
|
||||
{
|
||||
return $this->status === ConfigVersionStatus::Draft->value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user