SupportRequestRequest.php 957 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace App\Http\Requests;
  3. use App\Enums\SupportRequestCategoryEnum;
  4. use App\Enums\SupportRequestStatusEnum;
  5. use Illuminate\Foundation\Http\FormRequest;
  6. use Illuminate\Validation\Rule;
  7. class SupportRequestRequest extends FormRequest
  8. {
  9. public function rules(): array
  10. {
  11. if ($this->isMethod('PUT') || $this->isMethod('PATCH')) {
  12. return [
  13. 'status' => ['required', Rule::in(SupportRequestStatusEnum::toArray())],
  14. ];
  15. }
  16. return [
  17. 'category' => ['required', Rule::in(SupportRequestCategoryEnum::toArray())],
  18. 'title' => ['required', 'string', 'max:150'],
  19. 'message' => ['required', 'string', 'max:8000'],
  20. 'name' => ['sometimes', 'nullable', 'string', 'max:255'],
  21. 'email' => ['sometimes', 'nullable', 'email', 'max:255'],
  22. 'phone' => ['sometimes', 'nullable', 'string', 'max:30'],
  23. ];
  24. }
  25. }