OpenProjectRequest.php 930 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace App\Http\Requests\Coach;
  3. use Illuminate\Foundation\Http\FormRequest;
  4. /**
  5. * 技师开通项目请求验证
  6. */
  7. class OpenProjectRequest extends FormRequest
  8. {
  9. /**
  10. * 判断用户是否有权限进行此请求
  11. */
  12. public function authorize(): bool
  13. {
  14. return true;
  15. }
  16. /**
  17. * 获取验证规则
  18. *
  19. * @return array<string, mixed> 验证规则数组
  20. */
  21. public function rules(): array
  22. {
  23. return [
  24. 'project_id' => 'required|integer|exists:project,id',
  25. ];
  26. }
  27. /**
  28. * 获取验证错误消息
  29. *
  30. * @return array<string, string> 错误消息数组
  31. */
  32. public function messages(): array
  33. {
  34. return [
  35. 'project_id.required' => '项目ID不能为空',
  36. 'project_id.integer' => '项目ID必须是整数',
  37. 'project_id.exists' => '项目不存在',
  38. ];
  39. }
  40. }