75 lines
2.4 KiB
PHP
75 lines
2.4 KiB
PHP
<?php
|
|
|
|
/**
|
|
* 文件功能:后台签到奖励规则保存请求校验
|
|
*
|
|
* 集中校验连续签到天数、奖励数值与身份徽章配置。
|
|
*/
|
|
|
|
namespace App\Http\Requests\Admin;
|
|
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
/**
|
|
* 类功能:校验后台新增和更新签到奖励规则的表单数据。
|
|
*/
|
|
class SaveSignInRewardRuleRequest extends FormRequest
|
|
{
|
|
/**
|
|
* 方法功能:允许已通过后台权限中间件的管理员继续校验。
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* 方法功能:返回签到奖励规则表单的校验规则。
|
|
*
|
|
* @return array<string, ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
$ruleId = $this->route('signInRewardRule')?->id;
|
|
|
|
return [
|
|
'streak_days' => [
|
|
'required',
|
|
'integer',
|
|
'min:1',
|
|
'max:3650',
|
|
Rule::unique('sign_in_reward_rules', 'streak_days')->ignore($ruleId),
|
|
],
|
|
'gold_reward' => ['required', 'integer', 'min:0', 'max:999999999'],
|
|
'exp_reward' => ['required', 'integer', 'min:0', 'max:999999999'],
|
|
'charm_reward' => ['required', 'integer', 'min:0', 'max:999999999'],
|
|
'identity_badge_code' => ['nullable', 'string', 'max:50'],
|
|
'identity_badge_name' => ['nullable', 'string', 'max:50'],
|
|
'identity_badge_icon' => ['nullable', 'string', 'max:120'],
|
|
'identity_badge_color' => ['nullable', 'string', 'max:20'],
|
|
'identity_duration_days' => ['required', 'integer', 'min:0', 'max:3650'],
|
|
'sort_order' => ['required', 'integer', 'min:0', 'max:999999'],
|
|
'is_enabled' => ['nullable', 'boolean'],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* 方法功能:返回签到奖励规则表单的中文字段名。
|
|
*
|
|
* @return array<string, string>
|
|
*/
|
|
public function attributes(): array
|
|
{
|
|
return [
|
|
'streak_days' => '连续签到天数',
|
|
'gold_reward' => '金币奖励',
|
|
'exp_reward' => '经验奖励',
|
|
'charm_reward' => '魅力奖励',
|
|
'identity_badge_name' => '身份名称',
|
|
'identity_duration_days' => '身份有效天数',
|
|
];
|
|
}
|
|
}
|