50 lines
1.1 KiB
PHP
50 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Lottery\DrawResultBatchStatus;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
/** 开奖结果批次(含 RNG 种子摘要、审核人) {@see draw_result_batches} */
|
|
final class DrawResultBatch extends Model
|
|
{
|
|
public $timestamps = true;
|
|
|
|
protected $fillable = [
|
|
'draw_id',
|
|
'result_version',
|
|
'source_type',
|
|
'rng_seed_hash',
|
|
'raw_seed_encrypted',
|
|
'status',
|
|
'created_by',
|
|
'confirmed_by',
|
|
'confirmed_at',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'result_version' => 'integer',
|
|
'confirmed_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
public function draw(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Draw::class);
|
|
}
|
|
|
|
public function items(): HasMany
|
|
{
|
|
return $this->hasMany(DrawResultItem::class, 'result_batch_id');
|
|
}
|
|
|
|
public function statusEnum(): ?DrawResultBatchStatus
|
|
{
|
|
return DrawResultBatchStatus::tryFrom((string) $this->status);
|
|
}
|
|
}
|