@php // Get active languages for the restaurant $showArabic = $receiptSettings->show_arabic_on_receipt ?? false; $allActiveLanguages = collect(languages())->pluck('language_code')->toArray(); // Prioritize en and ar if both are available (common case like Lubab) // Otherwise use the first 2 active languages $primaryLang = 'en'; $secondaryLang = 'ar'; // If en is not in active languages, use first active language if (!in_array('en', $allActiveLanguages) && !empty($allActiveLanguages)) { $primaryLang = $allActiveLanguages[0]; } // If ar is not in active languages, use second active language or primary if only one if (!in_array('ar', $allActiveLanguages)) { if (count($allActiveLanguages) >= 2 && $allActiveLanguages[0] !== $primaryLang) { $secondaryLang = $allActiveLanguages[1]; } elseif (count($allActiveLanguages) >= 2) { // If primary is first, get second $secondaryLang = $allActiveLanguages[1]; } elseif (!empty($allActiveLanguages) && $allActiveLanguages[0] !== $primaryLang) { $secondaryLang = $allActiveLanguages[0]; } else { // If no other language, use same as primary (will only show one language) $secondaryLang = $primaryLang; } } // Ensure we have 2 different languages if ($primaryLang === $secondaryLang && count($allActiveLanguages) >= 2) { $secondaryLang = $allActiveLanguages[1] ?? 'en'; } // Helper function to get bilingual text $getBilingualText = function($key, $params = []) use ($showArabic, $primaryLang, $secondaryLang) { $currentLocale = app()->getLocale(); // Get primary language translation app()->setLocale($primaryLang); $primary = trans($key, $params); if ($showArabic) { // Get secondary language translation app()->setLocale($secondaryLang); $secondary = trans($key, $params); // Restore original locale app()->setLocale($currentLocale); // If secondary translation is same as key, it means translation doesn't exist, so just show primary if ($secondary === $key || empty($secondary)) { return $primary; } return $primary . ' / ' . $secondary; } // Restore original locale app()->setLocale($currentLocale); return $primary; }; // Helper function to get bilingual item name $getBilingualItemName = function($menuItem) use ($showArabic, $primaryLang, $secondaryLang) { if (!$menuItem) { return 'Item Not Found'; } $primaryName = $menuItem->getTranslatedValue('item_name', $primaryLang); if (!$primaryName) { $primaryName = $menuItem->item_name ?? 'Item Not Found'; } if ($showArabic) { $secondaryName = $menuItem->getTranslatedValue('item_name', $secondaryLang); // If secondary translation exists and is different, show both if ($secondaryName && $secondaryName !== $primaryName && $secondaryName !== $menuItem->item_name) { return $primaryName . ' / ' . $secondaryName; } } return $primaryName; }; @endphp
| {{ $getBilingualText('modules.order.qty') }} | {{ $getBilingualText('modules.menu.itemName') }} | {{ $getBilingualText('modules.order.price') }} | {{ $getBilingualText('modules.order.amount') }} |
|---|---|---|---|
| {{ $item->quantity }} |
{{ $getBilingualItemName($item->menuItem) }}
@if (isset($item->menuItemVariation) && $item->menuItemVariation)
({{ $item->menuItemVariation->variation }}) @endif @foreach ($item->modifierOptions as $modifier) • {{ $modifier->name }}
(+{{ currency_format($modifier->price, restaurant()->currency_id) }})
@endforeach
@if($item->note)
{{ $getBilingualText('modules.order.note') }}: {{ $item->note }}
@endif
@if($hasDiscount)
@if($discountPercent > 0) {{ number_format($discountPercent, 0) }}% OFF @else -{{ currency_format($discountAmount, restaurant()->currency_id) }} @endif @endif |
@if($hasDiscount)
{{ currency_format($originalPrice, restaurant()->currency_id) }}
@else
{{ currency_format($item->price, restaurant()->currency_id) }}
@endif
{{ currency_format($discountedPrice, restaurant()->currency_id) }} |
{{ currency_format($item->amount, restaurant()->currency_id) }} |