*/ public function rules(): array { $call = $this->route('call'); $creating = ! $call instanceof Call; $sometimes = $creating ? 'required' : 'sometimes'; return [ 'title' => [$sometimes, new Translatable(requireDefaultLocale: $creating, max: 255)], 'slug' => [ $sometimes, new Translatable(requireDefaultLocale: $creating, max: 255), new UniqueTranslatedSlug(Call::class, $call?->id), ], 'description' => ['sometimes', 'nullable', new Translatable], 'what_you_get' => ['sometimes', 'nullable', new Translatable], 'status' => ['sometimes', Rule::enum(CallStatus::class)], 'hours_per_week' => ['sometimes', 'nullable', 'integer', 'min:1', 'max:40'], 'duration_weeks' => ['sometimes', 'nullable', 'integer', 'min:1'], 'seniority' => ['sometimes', 'nullable', Rule::in(self::SENIORITIES)], 'opens_at' => ['sometimes', 'nullable', 'date'], 'closes_at' => ['sometimes', 'nullable', 'date', 'after_or_equal:opens_at'], 'project_id' => ['sometimes', 'nullable', 'integer', Rule::exists('projects', 'id')->whereNull('deleted_at')], 'technology_ids' => ['sometimes', 'array'], 'technology_ids.*' => ['integer', 'distinct', Rule::exists('technologies', 'id')], ]; } }