diff --git a/.env.example b/.env.example index 7899371..dc4e71a 100644 --- a/.env.example +++ b/.env.example @@ -36,4 +36,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 f519fec..80721c9 100644 --- a/app/Http/Controllers/Qr/QrCodeController.php +++ b/app/Http/Controllers/Qr/QrCodeController.php @@ -324,7 +324,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 4ce2aad..676ec39 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; @@ -85,23 +86,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/public/qr/landing.blade.php b/resources/views/public/qr/landing.blade.php index 38036bb..236f109 100644 --- a/resources/views/public/qr/landing.blade.php +++ b/resources/views/public/qr/landing.blade.php @@ -4,6 +4,7 @@ {{ $qrCode->label }} + @include('partials.favicon') @vite(['resources/css/app.css']) @@ -23,7 +24,7 @@ - @@ -31,7 +32,7 @@ View document - @@ -61,7 +62,7 @@ {{-- ===== VCARD ===== --}} @elseif($type === \App\Models\QrCode::TYPE_VCARD) @php - $avatarUrl = !empty($content['avatar_path']) ? route('qr.public.vcard.avatar', $qrCode->short_code) : null; + $avatarUrl = !empty($content['avatar_path']) ? $qrCode->publicPath('avatar') : null; $rawSocial = $content['social'] ?? []; $social = []; foreach ($rawSocial as $platform => $url) { @@ -158,7 +159,7 @@ {{-- Save contact button --}}
- Save Contact @@ -177,8 +178,8 @@ $bizColor = $content['brand_color'] ?? '#1e3a5f'; $bizHasLogo = !empty($content['logo_path']); $bizHasCover = !empty($content['cover_path']); - $bizLogoUrl = $bizHasLogo ? route('qr.public.business.logo', $qrCode->short_code) : null; - $bizCoverUrl = $bizHasCover ? route('qr.public.business.cover', $qrCode->short_code) : null; + $bizLogoUrl = $bizHasLogo ? $qrCode->publicPath('business-logo') : null; + $bizCoverUrl = $bizHasCover ? $qrCode->publicPath('business-cover') : null; $bizInitials = strtoupper(substr($bizName, 0, 1)); $bizRawSocial = $content['social'] ?? []; $bizSocial = []; @@ -312,8 +313,8 @@ $churchColor = $content['brand_color'] ?? '#1a3a5c'; $churchHasLogo = !empty($content['logo_path']); $churchHasCover = !empty($content['cover_path']); - $churchLogoUrl = $churchHasLogo ? route('qr.public.church.logo', $qrCode->short_code) : null; - $churchCoverUrl = $churchHasCover ? route('qr.public.church.cover', $qrCode->short_code) : null; + $churchLogoUrl = $churchHasLogo ? $qrCode->publicPath('church-logo') : null; + $churchCoverUrl = $churchHasCover ? $qrCode->publicPath('church-cover') : null; $churchInitials = strtoupper(substr($churchName, 0, 2)); $churchAcceptsPay = !empty($content['accepts_payment']); $churchCurrency = $content['currency'] ?? 'GHS'; @@ -324,7 +325,7 @@ $churchTypes, array_map(fn($t) => $legacyLabels[strtolower(trim($t))] ?? trim($t), $churchTypes) ); - $churchOrderRoute = route('qr.public.order', $qrCode->short_code); + $churchOrderRoute = $qrCode->publicPath('order'); $churchCsrf = csrf_token(); @endphp
short_code) : null; + $itinCoverUrl = $itinHasCover ? $qrCode->publicPath('itinerary-cover') : null; $itinTitle = $content['title'] ?? $qrCode->label; $itinDays = $content['days'] ?? []; $multiDay = count($itinDays) > 1; @@ -1028,7 +1029,7 @@

{{ $qrCode->label }}

@foreach($content['images'] ?? [] as $index => $image) - {{ $image['title'] ?? 'Image ' . ($index + 1) }} @@ -1038,7 +1039,7 @@ {{-- ===== APP ===== --}} @elseif($type === \App\Models\QrCode::TYPE_APP) -@php $appIconUrl = !empty($content['icon_path']) ? route('qr.public.app.icon', $qrCode->short_code) : null; @endphp +@php $appIconUrl = !empty($content['icon_path']) ? $qrCode->publicPath('app-icon') : null; @endphp
@if($appIconUrl) @@ -1131,14 +1132,14 @@ $sections = $content['sections'] ?? []; $title = $content['title'] ?? $qrCode->label; $acceptsPayment = (bool) ($content['accepts_payment'] ?? false); - $orderRoute = route('qr.public.order', $qrCode->short_code); + $orderRoute = $qrCode->publicPath('order'); $csrfToken = csrf_token(); $paystackPublicKey = $acceptsPayment ? app(\App\Services\Billing\PaystackService::class)->publicKey() : ''; $brandColor = $content['brand_color'] ?? ($isShop ? '#7c3aed' : '#f97316'); $hasLogo = !empty($content['logo_path']); $hasCover = !empty($content['cover_path']); - $logoUrl = $hasLogo ? route('qr.public.menu.logo', $qrCode->short_code) : null; - $coverUrl = $hasCover ? route('qr.public.menu.cover', $qrCode->short_code) : null; + $logoUrl = $hasLogo ? $qrCode->publicPath('menu-logo') : null; + $coverUrl = $hasCover ? $qrCode->publicPath('menu-cover') : null; $shippingType = $content['shipping_type'] ?? 'none'; $shippingFee = (float) ($content['shipping_fee'] ?? 0); $freeShippingAbove = (float) ($content['free_shipping_above'] ?? 0); @@ -1290,7 +1291,7 @@
{{-- Item image --}} @if($hasImage) - {{ $item['name'] }} @endif diff --git a/resources/views/qr-codes/create.blade.php b/resources/views/qr-codes/create.blade.php index 2245ffd..608fb32 100644 --- a/resources/views/qr-codes/create.blade.php +++ b/resources/views/qr-codes/create.blade.php @@ -84,7 +84,7 @@ status: '', timer: null, checkUrl: @js(route('user.qr-codes.check-slug')), - baseUrl: @js(\App\Models\QrCode::publicBaseUrl() . '/q'), + baseUrl: @js(\App\Support\LadillLink::baseUrl()), check() { clearTimeout(this.timer); const s = this.slug.trim(); @@ -104,7 +104,7 @@ :class="status === 'available' ? 'border-green-400' : status === 'taken' || status === 'invalid' ? 'border-red-400' : 'border-slate-200'"> - {{ \App\Models\QrCode::publicBaseUrl() }}/q/ + {{ \App\Support\LadillLink::baseUrl() }}/