56 lines
1021 B
PHP
56 lines
1021 B
PHP
<?php
|
|
|
|
/**
|
|
* 文件功能:节日福利领取记录模型
|
|
*
|
|
* 记录每个用户对每次节日活动的领取信息,保证一人只能领取一次。
|
|
*
|
|
* @author ChatRoom Laravel
|
|
*
|
|
* @version 1.0.0
|
|
*/
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class HolidayClaim extends Model
|
|
{
|
|
public $timestamps = false;
|
|
|
|
protected $fillable = [
|
|
'event_id',
|
|
'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');
|
|
}
|
|
|
|
/**
|
|
* 关联领取用户。
|
|
*/
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
}
|