@extends('layouts.dashboard') @section('content') @php /** * Vendor → Tables → QR → Design card. One printable design (a FRONT and a BACK) applied to every * table; the scan code on each printed card stays that table's own. Built on the SAME components as the * TV screen editor (tv.css chrome, the 3x3 position grid, the overlay switches), a background presets * grid, plus the app's standard FilePond uploader for a custom background. * * Layout: a full-width settings card, then a balanced two-card row — the controls card (a Front/Back * tab bar + the active side's controls) beside the live-preview card. * * @var array $config the saved (or default) QrCard design * @var array $creatives background presets [ ['image'=>path], ... ] * @var array $categories menu categories @var array $items available menu items */ use App\Models\QrCard; $config = $config ?? QrCard::defaultConfig(); $sides = ['front' => $config['front'], 'back' => $config['back']]; // This designer is shared: the SAME controls edit either the table-ordering card or the payment card // (its QR encodes the vendor's own static pay link). $type switches the copy + the pay-link field. $type = (($type ?? 'table') === 'payment') ? 'payment' : 'table'; $isPay = $type === 'payment'; // Payment is MANY named cards: $payCardId 0 = a new card, >0 = editing that card. The table card is // always singular. $isNewPay drives where the link field lives (create form vs its own Save-link form). $payCardId = (int) ($payCardId ?? 0); $payName = (string) ($payName ?? ''); $isNewPay = $isPay && $payCardId === 0; // Template mode: the admin authors a platform card template with this same designer. Values default to // the vendor's own flow, so a normal vendor edit is unchanged. $tplMode = $tplMode ?? false; $tplType = $tplType ?? ($isPay ? 'qr_pay' : 'qr_card'); $tplId = (int) ($tplId ?? 0); $backUrl = $backUrl ?? route('vendor.tables.qr'); $formAction = $formAction ?? ($isPay ? route('vendor.tables.qr.pay.post') : route('vendor.tables.qr.design')); $hasTableTemplates = $hasTableTemplates ?? false; $jsData = [ 'previewUrl' => $previewUrl ?? route('vendor.tables.qr.design.preview'), 'type' => $type, 'card' => [ 'orientation' => $config['orientation'], 'paper' => $config['paper'], 'cornerTl' => (int) $config['cornerTl'], 'cornerTr' => (int) $config['cornerTr'], 'cornerBr' => (int) $config['cornerBr'], 'cornerBl' => (int) $config['cornerBl'], 'theme' => $config['theme'], 'font' => $config['font'], 'accent' => $config['accent'], 'bgColor' => $config['bgColor'], 'poweredBy' => (bool) $config['poweredBy'], ], 'front' => $sides['front'], 'back' => $sides['back'], 'themeBg' => QrCard::THEME_BG, 'papers' => QrCard::PAPERS, 'i18n' => ['cancel' => t_raw('vendor.qr_card.crop_cancel'), 'apply' => t_raw('vendor.qr_card.crop_apply')], ]; /** One 3x3 position grid (the exact control the TV editor uses), current anchor pre-marked. */ $posGrid = static function (string $field, string $cur): string { $out = '
{{ t_raw($isPay ? 'vendor.qr_card.pay_form_sub' : 'vendor.qr_card.form_sub') }}