clusev/app/Services/DeploymentService.php

36 lines
1.1 KiB
PHP

<?php
namespace App\Services;
/**
* Read-only view of the panel's domain + TLS state. The panel domain is an
* INSTALL-TIME decision (APP_DOMAIN → config('clusev.domain')) because it must stay
* consistent with APP_URL, the Reverb (wss) endpoint, secure-cookie + HSTS settings,
* and Caddy's auto-TLS — none of which can be safely re-derived at runtime. TLS itself
* is fully automatic (Caddy issues + renews + redirects HTTP→HTTPS); the dashboard only
* SHOWS the status. To change the domain, re-run install.sh with the new domain.
*/
class DeploymentService
{
public function domain(): ?string
{
$domain = config('clusev.domain');
return ($domain !== null && $domain !== '') ? strtolower(trim((string) $domain)) : null;
}
/** True once a domain is configured — i.e. automatic TLS is in effect. */
public function hasTls(): bool
{
return $this->domain() !== null;
}
/** The HTTPS URL the panel is reachable at once a domain is configured. */
public function panelUrl(): ?string
{
$domain = $this->domain();
return $domain !== null ? 'https://'.$domain : null;
}
}