{{-- Menu email: the portal's recipe-card design rebuilt with tables and inline styles for mail clients. A menu built from components has no dishes, so its meals show their nutrition and ingredients only. Images are embedded in the message (see MenuMedia); the PDF is attached as before. --}} @php $isRecipeMenu = ($menu->generation_input['source'] ?? null) === \App\Services\RecipeMenuService::SOURCE; $isAr = app()->getLocale() === 'ar'; $dir = $isAr ? 'rtl' : 'ltr'; $start = $isAr ? 'right' : 'left'; $end = $isAr ? 'left' : 'right'; $font = "Tahoma, 'Segoe UI', Arial, sans-serif"; $media = app(\App\Services\MenuMedia::class)->using($message ?? null); $name = fn (array $r) => $isAr ? ($r['name_ar'] ?: $r['name_en']) : ($r['name_en'] ?: $r['name_ar']); $otherName = fn (array $r) => $isAr ? $r['name_en'] : $r['name_ar']; $itemName = fn (array $i) => ($isAr ? ($i['name_ar'] ?? null) : ($i['name_en'] ?? null)) ?: ($i['name'] ?? ''); $amount = fn (array $i) => rtrim(rtrim(number_format((float) $i['grams'], 1), '0'), '.') . ' ' . (($i['unit'] ?? null) === 'ml' ? __('common.ml') : __('common.grams')); $grams = __('common.grams'); $categories = \App\Models\Recipe::CORE_CATEGORIES; @endphp {{ $menu->title }}
{{-- Brand --}} {{-- Plan header + daily targets --}} @foreach ($days as $day) @if (count($days) > 1) @endif @foreach ($day['meals'] as $meal) @php $slot = $meal['slot']; $recipe = $meal['recipe'] ?? null; $items = collect($meal['items']); $stats = [ ['kcal', number_format((int) round($items->sum('calories'))), ''], ['fat', round($items->sum('fat_g'), 1), $grams], ['fiber', round($items->sum('fiber_g'), 1), $grams], ['protein', round($items->sum('protein_g'), 1), $grams], ['carbs', round($items->sum('carbs_g'), 1), $grams], ]; $pill = 'display:inline-block; border-radius:999px; padding:6px 14px; font-size:13px; font-weight:700; margin:0 0 4px;'; @endphp @endforeach @endforeach @if (($totalDays ?? count($days)) > count($days)) @endif {{-- Footer (the API's in-app preview reuses this page, with no attachment) --}} @if ($attachmentNote ?? true) @endif
@if ($logo = $media->logo(360)) Smart Carb @else
Smart Carb Nutritecs
@endif
{{ __('menus.recipes.email_greeting', ['name' => $menu->patient?->first_name ?? $menu->patient?->full_name]) }}
{{ $menu->title }} · {{ $menu->starts_on?->format('Y-m-d') }}
@foreach ([ [__('patients.target_calories'), number_format($menu->target_calories), __('menus.recipes.kcal'), '#5F8A31', '#F2F6E9'], [__('patients.protein'), $menu->protein_g, $grams, '#1B1813', '#F6F6F5'], [__('patients.carbs'), $menu->carbs_g, $grams, '#1B1813', '#F6F6F5'], [__('patients.fat'), $menu->fat_g, $grams, '#1B1813', '#F6F6F5'], ] as [$label, $value, $unit, $color, $bg]) @endforeach
{{ $label }}
{{ $value }} {{ $unit }}
 
{{ __('common.day') }} {{ $day['day'] }}
{{-- Tabs --}}
@if ($icon = $media->icon($slot)) @endif{{ __('menus.slots.' . $slot) }} @if ($recipe['is_super_meal'] ?? false) @if ($icon = $media->icon('super')) @endif{{ __('menus.recipes.super_meal') }} @endif @if ($recipe['is_new'] ?? false) {{ __('menus.recipes.new') }} @endif {{ __('menus.recipes.meal_target') }}: {{ number_format($meal['target_calories']) }} {{ __('menus.recipes.kcal') }}
@if ($recipe)
{{ $name($recipe) }}
@if ($otherName($recipe))
{{ $otherName($recipe) }}
@endif @if ($dish = $media->dish($recipe['image'] ?? null, 1200)) {{ $name($recipe) }} @endif @elseif ($isRecipeMenu)
{{ __('menus.recipes.fallback_note') }}
@endif {{-- Nutrition row --}} @foreach ($stats as $i => [$key, $value, $unit]) @endforeach
@if ($icon = $media->icon($key)) @endif
{{ $value }} {{ $unit }}
{{ __('menus.recipes.' . $key) }}
{{-- Core components + ingredients --}} @if ($recipe) @endif
{{ __('menus.recipes.core_components') }}
@foreach (array_chunk($categories, 4) as $row) @foreach ($row as $category) @php $on = in_array($category, $recipe['core_categories'] ?? [], true); @endphp @endforeach @endforeach
@if ($icon = $media->icon($category . ($on ? '-on' : '-off')))@endif
{{ __('menus.recipes.categories.' . $category) }}
{{-- The paid components the clinic has bought; locked ones stay off the reviewer's copy --}} @if (! empty($benefits['unlocked'])) @php $earned = $benefits['recipes'][$recipe['id']] ?? []; $shown = collect($benefits['all'])->whereIn('slug', $benefits['unlocked']); @endphp @foreach ($shown->chunk(4) as $row) @foreach ($row as $benefit) @php $on = in_array($benefit['slug'], $earned, true); @endphp @endforeach @endforeach
@if ($icon = $media->icon($benefit['slug'] . ($on ? '-on' : '-off')))@endif
{{ $benefit['name'] }}
@endif
{{ __('menus.recipes.ingredients') }}
@foreach ($meal['items'] as $item) @php $photo = \App\Services\RecipeMenuService::pickPhoto(($componentPhotos ?? [])[$item['component_id'] ?? 0] ?? [], (float) $item['grams']); $thumb = $photo ? $media->photo($photo, 96) : null; @endphp @endforeach
@if ($thumb) @else
@endif
{{ $itemName($item) }} {{ $amount($item) }}
 
{{ __('menus.email_more_days', ['count' => $totalDays - count($days)]) }}
{{ __('menus.recipes.email_pdf_note') }}
Smart Carb Nutritecs · {{ now()->format('Y-m-d') }}