123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace App\Http\Requests\API\CustomField;
- use App\Http\Requests\RuleHelper;
- use App\Models\Enums\CustomFieldType;
- use Illuminate\Foundation\Http\FormRequest;
- use Illuminate\Validation\Rule;
- use Illuminate\Validation\Rules\Enum;
- class CreateOrUpdateRequest extends FormRequest
- {
- use RuleHelper;
- /**
- * Determine if the user is authorized to make this request.
- */
- public function authorize(): bool
- {
- return true;
- }
- /**
- * Get the validation rules that apply to the request.
- *
- * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
- */
- public function rules(): array
- {
- return [
- 'key' => 'required',
- 'group' => 'required',
- 'type' => [
- 'required',
- new Enum(CustomFieldType::class),
- ],
- 'required' => 'in:0,1',
- 'label' => 'required|array',
- 'options' => 'array',
- ];
- }
- public function importRules(): array
- {
- return [
- 'key' => 'required',
- 'type' => [
- 'required',
- new Enum(CustomFieldType::class),
- ],
- 'custom_key'=> 'required_if:type,3',
- 'custom_value'=>'required',
- ];
- }
- }
|