*/ public function rules(): array { return [ 'channel_code' => ['prohibited'], 'competition_id' => ['prohibited'], 'channel_name' => ['sometimes', 'string', 'max:200'], 'status' => ['sometimes', Rule::in(SignupChannel::STATUSES)], 'shared_secret' => ['sometimes', 'string', 'max:255'], 'entry_encryption_enabled' => ['sometimes', 'boolean'], 'success_callback_url' => ['sometimes', 'nullable', 'url:http,https', 'max:2048'], 'success_callback_type' => ['sometimes', Rule::in(SignupChannel::CALLBACK_TYPES)], 'mini_program_callback_path' => [ 'nullable', 'string', 'max:1024', 'regex:/^\/(?!\/)[^#]*$/', Rule::requiredIf(fn (): bool => $this->resolvedCallbackType() === SignupChannel::CALLBACK_TYPE_MINI_PROGRAM), ], 'mini_program_callback_method' => ['sometimes', Rule::in(SignupChannel::MINI_PROGRAM_METHODS)], 'remark' => ['sometimes', 'nullable', 'string'], ]; } private function resolvedCallbackType(): string { $requestedType = $this->input('success_callback_type'); if (is_string($requestedType) && $requestedType !== '') { return $requestedType; } $channel = $this->route('signup_channel'); return $channel instanceof SignupChannel ? (string) $channel->success_callback_type : SignupChannel::CALLBACK_TYPE_WEB; } }