2026-04-28 23:42:48 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
2026-04-29 13:35:20 +08:00
|
|
|
* 文件功能:猜谜活动回合模型
|
2026-04-28 23:42:48 +08:00
|
|
|
*
|
2026-04-29 13:35:20 +08:00
|
|
|
* 每次出题对应一个回合,记录题型、题目、状态、奖励和获胜者。
|
2026-04-28 23:42:48 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
|
|
2026-04-29 10:32:12 +08:00
|
|
|
/**
|
2026-04-29 13:35:20 +08:00
|
|
|
* 类功能:记录猜谜活动每一轮的题型、奖励与结算状态。
|
2026-04-29 10:32:12 +08:00
|
|
|
*/
|
2026-04-29 13:35:20 +08:00
|
|
|
class RiddleGameRound extends Model
|
2026-04-28 23:42:48 +08:00
|
|
|
{
|
2026-04-29 13:35:20 +08:00
|
|
|
/**
|
|
|
|
|
* 属性功能:显式绑定历史回合表名,避免类名重命名后推导到错误表。
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected $table = 'idiom_game_rounds';
|
|
|
|
|
|
2026-04-29 10:32:12 +08:00
|
|
|
/**
|
|
|
|
|
* 方法功能:声明可批量赋值的回合字段。
|
|
|
|
|
*
|
|
|
|
|
* @var array<int, string>
|
|
|
|
|
*/
|
2026-04-28 23:42:48 +08:00
|
|
|
protected $fillable = [
|
|
|
|
|
'room_id',
|
|
|
|
|
'idiom_id',
|
2026-04-29 13:35:20 +08:00
|
|
|
'quiz_type',
|
2026-04-28 23:42:48 +08:00
|
|
|
'status',
|
|
|
|
|
'reward_gold',
|
|
|
|
|
'reward_exp',
|
|
|
|
|
'winner_id',
|
|
|
|
|
'winner_username',
|
|
|
|
|
'started_at',
|
|
|
|
|
'ended_at',
|
|
|
|
|
];
|
|
|
|
|
|
2026-04-29 10:32:12 +08:00
|
|
|
/**
|
|
|
|
|
* 方法功能:定义回合字段的类型转换规则。
|
|
|
|
|
*
|
|
|
|
|
* @return array<string, string>
|
|
|
|
|
*/
|
2026-04-28 23:42:48 +08:00
|
|
|
protected function casts(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
2026-04-29 13:35:20 +08:00
|
|
|
'room_id' => 'integer',
|
|
|
|
|
'idiom_id' => 'integer',
|
2026-04-28 23:42:48 +08:00
|
|
|
'reward_gold' => 'integer',
|
|
|
|
|
'reward_exp' => 'integer',
|
|
|
|
|
'started_at' => 'datetime',
|
|
|
|
|
'ended_at' => 'datetime',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-29 10:32:12 +08:00
|
|
|
/**
|
2026-04-29 13:35:20 +08:00
|
|
|
* 方法功能:关联本回合对应的猜谜题目。
|
2026-04-29 10:32:12 +08:00
|
|
|
*/
|
2026-04-28 23:42:48 +08:00
|
|
|
public function idiom(): BelongsTo
|
|
|
|
|
{
|
2026-04-29 13:35:20 +08:00
|
|
|
return $this->belongsTo(Riddle::class);
|
2026-04-28 23:42:48 +08:00
|
|
|
}
|
|
|
|
|
}
|