12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- namespace App\Http\Requests\Coach;
- use Illuminate\Foundation\Http\FormRequest;
- /**
- * 技师项目设置请求验证
- */
- class SetProjectRequest extends FormRequest
- {
- /**
- * 判断用户是否有权限进行此请求
- */
- public function authorize(): bool
- {
- return true;
- }
- /**
- * 获取验证规则
- *
- * @return array<string, mixed> 验证规则数组
- */
- public function rules(): array
- {
- return [
- 'project_id' => 'required|integer|exists:project,id',
- 'voucher' => 'nullable|numeric|min:0|max:10',
- 'gender' => 'nullable|integer|in:0,1,2',
- 'traffic_fee_type' => 'nullable|integer|in:0,1,2',
- ];
- }
- /**
- * 获取验证错误消息
- *
- * @return array<string, string> 错误消息数组
- */
- public function messages(): array
- {
- return [
- 'project_id.required' => '项目ID不能为空',
- 'project_id.integer' => '项目ID必须是整数',
- 'project_id.exists' => '项目不存在',
- 'voucher.numeric' => '代金券金额必须是数字',
- 'voucher.min' => '代金券金额不能小于0元',
- 'voucher.max' => '代金券金额不能超过10元',
- 'gender.integer' => '顾客性别设置必须是整数',
- 'gender.in' => '顾客性别设置值无效',
- 'traffic_fee_type.integer' => '交通费类型必须是整数',
- 'traffic_fee_type.in' => '交通费类型值无效',
- ];
- }
- }
|