Files
ladill-frontdesk/app/Services/Printers/PrinterManager.php
T
isaaccladandCursor 9e2d79936c
Deploy Ladill Frontdesk / deploy (push) Failing after 35s
Test / test (push) Failing after 2m45s
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>
2026-06-27 20:37:15 +00:00

43 lines
1.1 KiB
PHP

<?php
namespace App\Services\Printers;
use App\Contracts\Printers\PrinterDriverInterface;
use App\Models\Visit;
use InvalidArgumentException;
class PrinterManager
{
/** @var array<string, PrinterDriverInterface> */
protected array $drivers = [];
public function __construct()
{
$this->register(new PdfPrinterDriver);
$this->register(new ZebraPrinterDriver);
$this->register(new BrotherPrinterDriver);
$this->register(new DymoPrinterDriver);
}
public function register(PrinterDriverInterface $driver): void
{
$this->drivers[$driver->name()] = $driver;
}
public function driver(?string $name = null): PrinterDriverInterface
{
$name = $name ?? config('frontdesk.printers.default_driver', 'pdf');
if (! isset($this->drivers[$name])) {
throw new InvalidArgumentException("Unknown printer driver: {$name}");
}
return $this->drivers[$name];
}
public function renderBadge(Visit $visit, ?string $driver = null): array
{
return $this->driver($driver)->renderBadge($visit);
}
}