{{-- --}}
@php
$companyId = Auth::check() ? Auth::user()->company_id : null;
if ($companyId) {
// Get KOT printer setting and ensure it's always an array
$rawKotPrinter = App\Models\Setting::getValue('kot_printer', $companyId);
$kotPrinterSetting = is_array($rawKotPrinter)
? $rawKotPrinter
: json_decode($rawKotPrinter, true);
// fallback to empty array if decoding failed
$kotPrinterSetting = is_array($kotPrinterSetting) ? $kotPrinterSetting : [];
// Get KOT counter-wise flag
$kotCounterWise = (int) App\Models\Setting::getValue('kot_counter_wise', $companyId);
// Show print button if printers exist, not 'none', and counter-wise is 0
$showKotPrintButton = !empty($kotPrinterSetting)
&& !in_array('none', $kotPrinterSetting);
} else {
$kotPrinterSetting = [];
$kotCounterWise = 0;
$showKotPrintButton = false;
}
@endphp