service = $service; } /** * Get the dynamic validation rules for the form. * * @return array */ public function rules(): array { $rules = [ 'name' => 'required|string|max:255|min:3', 'providerId' => 'required|numeric|min:1|exists:connection_providers,id', 'protocolId' => 'required|numeric|min:1|exists:connection_protocols,id', 'statusId' => 'required|numeric|min:1|exists:connection_statuses,id', ]; $protocol = \App\Models\ConnectionProtocol::find($this->protocolId); if ($protocol && 'saml' === mb_strtolower($protocol->name)) { $rules['samlEntityId'] = 'required|string|min:3'; $rules['samlAcsUrl'] = 'required|url'; } return $rules; } /** * This sets the form to edit mode, after fetching the connected app of * the given id. */ public function set(ConnectedAppData $data): void { $this->name = $data->name; $this->protocolId = $data->protocolId; $this->providerId = $data->providerId; $this->statusId = $data->statusId; $this->samlEntityId = $data->settings['saml']['entity_id'] ?? ''; $this->samlAcsUrl = $data->settings['saml']['acs_url'] ?? ''; } }