You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.0 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Request\v3;
  4. use App\Model\v3\User;
  5. use App\Request\BaseFormRequest;
  6. use Hyperf\Utils\ApplicationContext;
  7. class CommunityBindRequest extends BaseFormRequest
  8. {
  9. /**
  10. * Determine if the user is authorized to make this request.
  11. */
  12. public function authorize(): bool
  13. {
  14. return true;
  15. }
  16. /**
  17. * Get the validation rules that apply to the request.
  18. */
  19. public function rules(): array
  20. {
  21. $userTable = ApplicationContext::getContainer()->get(User::class)->getTable();
  22. return [
  23. 'source_id' => 'required|nonempty',
  24. 'user_id' => 'required|nonempty|exists_enable:'.$userTable.',id',
  25. 'json_data' => 'json',
  26. ];
  27. }
  28. public function messages(): array
  29. {
  30. return [
  31. '*.nonempty' => ':attribute参数异常',
  32. 'user_id.exists_enable' => '用户不存在',
  33. ];
  34. }
  35. public function attributes(): array
  36. {
  37. return [
  38. ];
  39. }
  40. }