2026-03-01 20:06:53 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 文件功能:节日福利领取记录模型
|
|
|
|
|
*
|
|
|
|
|
* 记录每个用户对每次节日活动的领取信息,保证一人只能领取一次。
|
|
|
|
|
*
|
|
|
|
|
* @author ChatRoom Laravel
|
|
|
|
|
*
|
|
|
|
|
* @version 1.0.0
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
|
|
2026-04-21 17:53:11 +08:00
|
|
|
/**
|
|
|
|
|
* 类功能:记录用户在某个节日福利发放批次中的领取状态。
|
|
|
|
|
*/
|
2026-03-01 20:06:53 +08:00
|
|
|
class HolidayClaim extends Model
|
|
|
|
|
{
|
|
|
|
|
public $timestamps = false;
|
|
|
|
|
|
|
|
|
|
protected $fillable = [
|
|
|
|
|
'event_id',
|
2026-04-21 17:53:11 +08:00
|
|
|
'run_id',
|
2026-03-01 20:06:53 +08:00
|
|
|
'user_id',
|
|
|
|
|
'amount',
|
|
|
|
|
'claimed_at',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 属性类型转换。
|
|
|
|
|
*/
|
|
|
|
|
protected function casts(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'claimed_at' => 'datetime',
|
|
|
|
|
'amount' => 'integer',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 关联节日活动。
|
|
|
|
|
*/
|
|
|
|
|
public function event(): BelongsTo
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(HolidayEvent::class, 'event_id');
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-21 17:53:11 +08:00
|
|
|
/**
|
|
|
|
|
* 关联所属发放批次。
|
|
|
|
|
*/
|
|
|
|
|
public function run(): BelongsTo
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(HolidayEventRun::class, 'run_id');
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-01 20:06:53 +08:00
|
|
|
/**
|
|
|
|
|
* 关联领取用户。
|
|
|
|
|
*/
|
|
|
|
|
public function user(): BelongsTo
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(User::class);
|
|
|
|
|
}
|
|
|
|
|
}
|