diff --git a/.env.example b/.env.example index cc3811d..ed385c9 100644 --- a/.env.example +++ b/.env.example @@ -46,4 +46,6 @@ AFIA_PROVIDER=openai AFIA_MODEL=gpt-4o-mini AFIA_API_KEY= +LINK_PUBLIC_DOMAIN=ladl.link + VITE_APP_NAME="${APP_NAME}" diff --git a/app/Http/Controllers/Qr/QrCodeController.php b/app/Http/Controllers/Qr/QrCodeController.php index 879af1b..ea377d6 100644 --- a/app/Http/Controllers/Qr/QrCodeController.php +++ b/app/Http/Controllers/Qr/QrCodeController.php @@ -313,7 +313,7 @@ class QrCodeController extends Controller } } - $png = $this->imageGenerator->renderPng(QrCode::publicBaseUrl() . '/q/' . $shortCode, $style); + $png = $this->imageGenerator->renderPng(\App\Support\LadillLink::url($shortCode), $style); if ($tempLogoPath) { Storage::disk('qr')->delete($tempLogoPath); diff --git a/app/Models/QrCode.php b/app/Models/QrCode.php index 8bf267b..a886aa3 100644 --- a/app/Models/QrCode.php +++ b/app/Models/QrCode.php @@ -2,6 +2,7 @@ namespace App\Models; +use App\Support\LadillLink; use App\Support\Qr\QrStyleDefaults; use App\Support\Qr\QrTypeCatalog; use App\Support\Qr\QrWifiPayload; @@ -81,23 +82,19 @@ class QrCode extends Model public function publicUrl(): string { - return self::publicBaseUrl() . '/q/' . $this->short_code; + return LadillLink::url($this->short_code); + } + + public function publicPath(string $suffix = ''): string + { + return $suffix === '' + ? $this->publicUrl() + : LadillLink::path($this->short_code, $suffix); } - /** - * Base URL for public QR links. Always the short platform domain - * (ladill.com) — never the signed-in account/product host — so printed - * codes and shared links stay short and host-independent of where the QR - * was created. - */ public static function publicBaseUrl(): string { - $appUrl = (string) config('app.url'); - $scheme = parse_url($appUrl, PHP_URL_SCHEME) ?: 'https'; - $host = (string) config('app.platform_domain') - ?: (parse_url($appUrl, PHP_URL_HOST) ?: 'ladill.com'); - - return $scheme . '://' . $host; + return LadillLink::baseUrl(); } /** diff --git a/app/Support/LadillLink.php b/app/Support/LadillLink.php new file mode 100644 index 0000000..3a51bc0 --- /dev/null +++ b/app/Support/LadillLink.php @@ -0,0 +1,26 @@ + env('LINK_PUBLIC_DOMAIN', 'ladl.link'), +]; diff --git a/resources/views/give/giving-pages/index.blade.php b/resources/views/give/giving-pages/index.blade.php index 111c939..2802806 100644 --- a/resources/views/give/giving-pages/index.blade.php +++ b/resources/views/give/giving-pages/index.blade.php @@ -24,7 +24,7 @@
{{ $qr->label }}
{{ $qr->content()['name'] ?? 'Organisation' }}
-{{ $qr->is_active ? 'Active' : 'Inactive' }} · /q/{{ $qr->short_code }}
+{{ $qr->is_active ? 'Active' : 'Inactive' }} · {{ $qr->publicUrl() }}