2
0

StoreDiscussionRequest.php 922 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace App\Http\Requests;
  3. use App\Services\AuthService;
  4. use Illuminate\Foundation\Http\FormRequest;
  5. class StoreDiscussionRequest extends FormRequest
  6. {
  7. private $user;
  8. /**
  9. * Determine if the user is authorized to make this request.
  10. *
  11. * @return bool
  12. */
  13. public function authorize()
  14. {
  15. $user = AuthService::current($this);
  16. if (! $user) {
  17. return false;
  18. }
  19. $this->user = $user;
  20. return true;
  21. }
  22. /**
  23. * Get the validation rules that apply to the request.
  24. */
  25. public function rules(): array
  26. {
  27. return [
  28. 'res_id' => 'required|string',
  29. 'res_type' => 'required|string',
  30. ];
  31. }
  32. public function messages(): array
  33. {
  34. return [
  35. 'res_id.required' => 'res_type是必填项',
  36. 'res_type.required' => 'type是必填项',
  37. ];
  38. }
  39. }