CreateOrUpdateRequest.php 930 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace App\Http\Requests\API\CustomField;
  3. use App\Models\Enums\CustomFieldType;
  4. use Illuminate\Foundation\Http\FormRequest;
  5. use Illuminate\Validation\Rules\Enum;
  6. class CreateOrUpdateRequest extends FormRequest
  7. {
  8. /**
  9. * Determine if the user is authorized to make this request.
  10. */
  11. public function authorize(): bool
  12. {
  13. return true;
  14. }
  15. /**
  16. * Get the validation rules that apply to the request.
  17. *
  18. * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
  19. */
  20. public function rules(): array
  21. {
  22. return [
  23. 'key' => 'required',
  24. 'group' => 'required',
  25. 'type' => [
  26. 'required',
  27. new Enum(CustomFieldType::class),
  28. ],
  29. 'required' => 'in:0,1',
  30. 'label' => 'required|array',
  31. 'options' => 'array',
  32. ];
  33. }
  34. }