Visitor management app with SSO, kiosk, badges, reports, and Gitea CI deploy to frontdesk.ladill.com. Co-authored-by: Cursor <cursoragent@cursor.com>
36 lines
1009 B
PHP
36 lines
1009 B
PHP
<?php
|
|
|
|
namespace App\Services\Printers;
|
|
|
|
use App\Contracts\Printers\PrinterDriverInterface;
|
|
use App\Models\Visit;
|
|
|
|
class ZebraPrinterDriver implements PrinterDriverInterface
|
|
{
|
|
public function name(): string
|
|
{
|
|
return 'zebra';
|
|
}
|
|
|
|
public function renderBadge(Visit $visit): array
|
|
{
|
|
$visit->load(['visitor', 'host']);
|
|
$name = strtoupper(substr($visit->visitor->full_name, 0, 24));
|
|
$company = strtoupper(substr($visit->visitor->company ?? '', 0, 20));
|
|
$host = strtoupper(substr($visit->host?->name ?? '', 0, 20));
|
|
$code = $visit->badge_code;
|
|
|
|
$zpl = "^XA^FO50,50^A0N,40,40^FD{$name}^FS";
|
|
$zpl .= "^FO50,100^A0N,25,25^FD{$company}^FS";
|
|
$zpl .= "^FO50,140^A0N,25,25^FDHost: {$host}^FS";
|
|
$zpl .= "^FO50,180^BQN,2,5^FDQA,{$code}^FS";
|
|
$zpl .= "^XZ";
|
|
|
|
return [
|
|
'format' => 'zpl',
|
|
'content' => $zpl,
|
|
'filename' => 'badge-'.$visit->badge_code.'.zpl',
|
|
];
|
|
}
|
|
}
|