新增每日签到与补签卡功能
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:每日签到奖励规则模型。
|
||||
*
|
||||
* 通过连续签到天数门槛配置金币、经验、魅力与身份徽章奖励。
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
/**
|
||||
* 类功能:封装签到奖励规则字段、类型转换与命中签到记录关联。
|
||||
*/
|
||||
class SignInRewardRule extends Model
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\SignInRewardRuleFactory> */
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* 允许批量赋值的字段。
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'streak_days',
|
||||
'gold_reward',
|
||||
'exp_reward',
|
||||
'charm_reward',
|
||||
'identity_badge_code',
|
||||
'identity_badge_name',
|
||||
'identity_badge_icon',
|
||||
'identity_badge_color',
|
||||
'identity_duration_days',
|
||||
'is_enabled',
|
||||
'sort_order',
|
||||
];
|
||||
|
||||
/**
|
||||
* 属性类型转换。
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'streak_days' => 'integer',
|
||||
'gold_reward' => 'integer',
|
||||
'exp_reward' => 'integer',
|
||||
'charm_reward' => 'integer',
|
||||
'identity_duration_days' => 'integer',
|
||||
'is_enabled' => 'boolean',
|
||||
'sort_order' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 关联:命中过该规则的签到记录。
|
||||
*/
|
||||
public function dailySignIns(): HasMany
|
||||
{
|
||||
return $this->hasMany(DailySignIn::class, 'reward_rule_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user