46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 文件功能:会员个性化欢迎语与离开语设置验证器
|
||
|
|
* 负责校验会员中心提交的自定义进退场文案。
|
||
|
|
*/
|
||
|
|
|
||
|
|
namespace App\Http\Requests;
|
||
|
|
|
||
|
|
use Illuminate\Foundation\Http\FormRequest;
|
||
|
|
|
||
|
|
class UpdateVipPresenceSettingsRequest extends FormRequest
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* 判断当前登录用户是否允许提交会员个性化设置。
|
||
|
|
*/
|
||
|
|
public function authorize(): bool
|
||
|
|
{
|
||
|
|
return $this->user() !== null;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 获取会员个性化设置的验证规则。
|
||
|
|
*/
|
||
|
|
public function rules(): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'custom_join_message' => ['nullable', 'string', 'max:255'],
|
||
|
|
'custom_leave_message' => ['nullable', 'string', 'max:255'],
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 获取会员个性化设置的中文错误提示。
|
||
|
|
*
|
||
|
|
* @return array<string, string>
|
||
|
|
*/
|
||
|
|
public function messages(): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'custom_join_message.max' => '欢迎语最多只能填写 255 个字符。',
|
||
|
|
'custom_leave_message.max' => '离开语最多只能填写 255 个字符。',
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|