Initial Ladill Frontdesk release with deploy pipeline.
Visitor management app with SSO, kiosk, badges, reports, and Gitea CI deploy to frontdesk.ladill.com. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Frontdesk;
|
||||
|
||||
use App\Models\Organization;
|
||||
use App\Models\Visit;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class BadgeRenderService
|
||||
{
|
||||
public function __construct(
|
||||
protected QrCodeService $qrCodes,
|
||||
) {}
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
public function templateFor(Organization $organization): array
|
||||
{
|
||||
return array_merge(config('frontdesk.default_badge_template', []), $organization->settings['badge_template'] ?? []);
|
||||
}
|
||||
|
||||
public function renderHtml(Visit $visit, bool $autoPrint = false): string
|
||||
{
|
||||
$visit->load(['visitor', 'host', 'organization']);
|
||||
|
||||
return view('frontdesk.badges.render', [
|
||||
'visit' => $visit,
|
||||
'template' => $this->templateFor($visit->organization),
|
||||
'photoUrl' => $this->photoUrl($visit),
|
||||
'qrSvg' => $visit->qr_token ? $this->qrCodes->svg($visit, 120) : null,
|
||||
'autoPrint' => $autoPrint,
|
||||
'preview' => false,
|
||||
])->render();
|
||||
}
|
||||
|
||||
public function photoUrl(Visit $visit): ?string
|
||||
{
|
||||
$path = $visit->photo_path ?? $visit->visitor?->photo_path;
|
||||
|
||||
return $path && Storage::disk('public')->exists($path)
|
||||
? Storage::disk('public')->url($path)
|
||||
: null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user