Files
chatroom/app/Models/MysteryBoxClaim.php

55 lines
1.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* 文件功能:神秘箱子领取记录模型
*
* 记录每次神秘箱被用户发送暗号成功领取后的详情(关联箱子 + 领取者 + 实际奖励)。
* 对应表mystery_box_claims
*
* @author ChatRoom Laravel
*
* @version 1.0.0
*/
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class MysteryBoxClaim extends Model
{
protected $fillable = [
'mystery_box_id',
'user_id',
'reward_amount',
];
/**
* 属性类型转换。
*/
protected function casts(): array
{
return [
'reward_amount' => 'integer',
];
}
// ─── 关联关系 ────────────────────────────────────────────────────
/**
* 关联神秘箱子。
*/
public function mysteryBox(): BelongsTo
{
return $this->belongsTo(MysteryBox::class);
}
/**
* 关联领取用户。
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
}