47 lines
1015 B
PHP
47 lines
1015 B
PHP
<?php
|
|
|
|
/**
|
|
* 文件功能:创建 VIP 支付订单请求
|
|
* 负责校验前台用户发起 VIP 购买时提交的会员等级参数
|
|
*/
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class CreateVipPaymentOrderRequest extends FormRequest
|
|
{
|
|
/**
|
|
* 判断当前用户是否允许发起购买
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return $this->user() !== null;
|
|
}
|
|
|
|
/**
|
|
* 获取字段校验规则
|
|
*
|
|
* @return array<string, array<int, string>>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'vip_level_id' => ['required', 'integer', 'exists:vip_levels,id'],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* 获取中文错误提示
|
|
*
|
|
* @return array<string, string>
|
|
*/
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'vip_level_id.required' => '请选择要购买的 VIP 等级',
|
|
'vip_level_id.exists' => '所选 VIP 等级不存在或已被删除',
|
|
];
|
|
}
|
|
}
|