@@ -120,7 +120,7 @@ public function setSrvRecordAttribute(bool $isSrvRecord): void
120120 if ($ isSrvRecord ) {
121121 $ this ->attributes ['record_type ' ] = 'SRV ' ;
122122 } else {
123- $ ip = $ this ->server ? ->allocation?->ip;
123+ $ ip = $ this ->server ->allocation ?->ip;
124124 if (!empty ($ ip ) && filter_var ($ ip , FILTER_VALIDATE_IP , FILTER_FLAG_IPV6 )) {
125125 $ this ->attributes ['record_type ' ] = 'AAAA ' ;
126126 } else {
@@ -133,7 +133,7 @@ protected function upsertOnCloudflare(): bool
133133 {
134134 $ registrar = app (CloudflareService::class);
135135
136- $ zoneId = $ this ->domain ? ->cloudflare_id;
136+ $ zoneId = $ this ->domain ->cloudflare_id ;
137137 if (empty ($ zoneId )) {
138138 Log::warning ('Cloudflare zone id missing for domain ' , ['domain_id ' => $ this ->domain_id ]);
139139
@@ -172,7 +172,8 @@ protected function upsertOnCloudflare(): bool
172172 return false ;
173173 }
174174
175- if (empty ($ this ->server ?->node->srv_target )) {
175+ // @phpstan-ignore variable.undefined
176+ if (empty ($ this ->server ->node ->srv_target )) {
176177 Log::warning ('Node missing SRV target for SRV record ' , ['node_id ' => $ this ->server ->node ?->id]);
177178 Notification::make ()
178179 ->danger ()
@@ -184,7 +185,7 @@ protected function upsertOnCloudflare(): bool
184185 }
185186
186187 $ recordName = sprintf ('%s.%s.%s ' , $ serviceRecordType ->service (), $ serviceRecordType ->protocol (), $ this ->name );
187-
188+ // @phpstan-ignore variable.undefined
188189 $ result = $ registrar ->upsertDnsRecord ($ zoneId , $ recordName , 'SRV ' , $ this ->server ->node ->srv_target , $ this ->cloudflare_id , $ port );
189190
190191 if ($ result ['success ' ] && !empty ($ result ['id ' ])) {
@@ -198,20 +199,20 @@ protected function upsertOnCloudflare(): bool
198199 Notification::make ()
199200 ->danger ()
200201 ->title (trans ('subdomains::strings.notifications.cloudflare_upsert_failed_title ' ))
201- ->body (trans ('subdomains::strings.notifications.cloudflare_upsert_failed ' , ['subdomain ' => $ this ->name . '. ' . ($ this ->domain ->name ?? 'unknown ' ), 'errors ' => json_encode ($ result ['errors ' ] ?? $ result [ ' body ' ] ?? [] )]))
202+ ->body (trans ('subdomains::strings.notifications.cloudflare_upsert_failed ' , ['subdomain ' => $ this ->name . '. ' . ($ this ->domain ->name ?? 'unknown ' ), 'errors ' => json_encode ($ result ['errors ' ])]))
202203 ->send ();
203204
204205 return false ;
205206 }
206207
207208 // A/AAAA
208- $ ip = $ this ->server ? ->allocation?->ip;
209+ $ ip = $ this ->server ->allocation ?->ip;
209210 if (empty ($ ip ) || $ ip === '0.0.0.0 ' || $ ip === ':: ' ) {
210211 Log::warning ('Server allocation missing or invalid IP ' , ['server_id ' => $ this ->server_id ]);
211212 Notification::make ()
212213 ->danger ()
213214 ->title (trans ('subdomains::strings.notifications.cloudflare_missing_ip_title ' ))
214- ->body (trans ('subdomains::strings.notifications.cloudflare_missing_ip ' , ['subdomain ' => $ this ->name . '. ' . ($ this ->domain ? ->name ?? 'unknown ' )]))
215+ ->body (trans ('subdomains::strings.notifications.cloudflare_missing_ip ' , ['subdomain ' => $ this ->name . '. ' . ($ this ->domain ->name ?? 'unknown ' )]))
215216 ->send ();
216217
217218 return false ;
@@ -227,14 +228,14 @@ protected function upsertOnCloudflare(): bool
227228 return true ;
228229 }
229230
230- $ domainName = $ this ->domain ? ->name ?? 'unknown ' ;
231+ $ domainName = $ this ->domain ->name ?? 'unknown ' ;
231232 $ subdomain = sprintf ('%s.%s ' , $ this ->name , $ domainName );
232233
233234 Log::error ('Failed to upsert record on Cloudflare for Subdomain ID ' . $ this ->id , ['result ' => $ result ]);
234235 Notification::make ()
235236 ->danger ()
236237 ->title (trans ('subdomains::strings.notifications.cloudflare_upsert_failed_title ' ))
237- ->body (trans ('subdomains::strings.notifications.cloudflare_upsert_failed ' , ['subdomain ' => $ subdomain , 'errors ' => json_encode ($ result ['errors ' ] ?? $ result [ ' body ' ] ?? [] )]))
238+ ->body (trans ('subdomains::strings.notifications.cloudflare_upsert_failed ' , ['subdomain ' => $ subdomain , 'errors ' => json_encode ($ result ['errors ' ])]))
238239 ->send ();
239240
240241 return false ;
@@ -254,7 +255,7 @@ protected function deleteOnCloudflare(): bool
254255 Notification::make ()
255256 ->danger ()
256257 ->title (trans ('subdomains::strings.notifications.cloudflare_delete_failed_title ' ))
257- ->body (trans ('subdomains::strings.notifications.cloudflare_delete_failed ' , ['subdomain ' => $ this ->name . '. ' . ($ this ->domain ?->name ?? 'unknown ' ), 'errors ' => json_encode ($ result ['errors ' ] ?? $ result [ ' body ' ] ?? [] )]))
258+ ->body (trans ('subdomains::strings.notifications.cloudflare_delete_failed ' , ['subdomain ' => $ this ->name . '. ' . ($ this ->domain ?->name ?? 'unknown ' ), 'errors ' => json_encode ($ result ['errors ' ])]))
258259 ->send ();
259260
260261 return false ;
0 commit comments