IndexAdminAgentFeedbackRequest.php 974 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace App\Http\Requests\V3;
  3. use App\Models\AgentFeedback;
  4. use Illuminate\Foundation\Http\FormRequest;
  5. use Illuminate\Validation\Rule;
  6. /**
  7. * `GET /v3/admin/agent-feedback` 的入参:管理员审阅用户评价。
  8. */
  9. class IndexAdminAgentFeedbackRequest extends FormRequest
  10. {
  11. public function authorize(): bool
  12. {
  13. return true;
  14. }
  15. /**
  16. * @return array<string, array<int, mixed>>
  17. */
  18. public function rules(): array
  19. {
  20. return [
  21. 'filter.rating' => ['sometimes', 'string', 'in:1,-1'],
  22. 'filter.tag' => ['sometimes', Rule::in([...AgentFeedback::UP_TAGS, ...AgentFeedback::DOWN_REASONS])],
  23. 'filter.has_comment' => ['sometimes', 'in:true,false,1,0'],
  24. 'from' => ['sometimes', 'date_format:Y-m-d'],
  25. 'to' => ['sometimes', 'date_format:Y-m-d'],
  26. 'page' => ['integer', 'min:1'],
  27. 'per_page' => ['integer', 'min:1', 'max:100'],
  28. ];
  29. }
  30. }