@php /** @var \Illuminate\Support\Collection $templates */ $catColors = [ // WhatsApp/Meta categories — what the library badge + tabs show. 'marketing' => 'bg-accent-coral/15 text-[#A1431F]', 'authentication' => 'bg-[#13478A]/10 text-[#13478A]', 'utility' => 'bg-[#DFF1ED] text-wa-deep', // Legacy local verticals (fallback when no meta_category is set). 'travel' => 'bg-wa-bubble text-wa-deep', 'healthcare' => 'bg-[#DFF1ED] text-wa-deep', 'education' => 'bg-[#F4E9C9] text-[#7B5A14]', 'ecommerce' => 'bg-accent-coral/15 text-[#A1431F]', 'festival' => 'bg-[#EFE5F5] text-[#5B3D8A]', 'finance' => 'bg-[#13478A]/10 text-[#13478A]', ]; $statusDot = [ 'approved' => 'bg-wa-green', 'public' => 'bg-wa-green', 'pending' => 'bg-accent-amber', 'rejected' => 'bg-accent-coral', ]; @endphp @forelse ($templates as $t) @php // Badge/filter use the WhatsApp category (meta_category); fall back to // the local vertical only when a template has no Meta category yet. $catKey = $t->meta_category ?: $t->category; $cls = $catColors[$catKey] ?? 'bg-paper-50 text-ink-700'; // A WABA template with no Meta Template ID isn't in review — neutral dot // (matches the "Not submitted" label from status_label). $notSubmitted = (string) $t->channel === 'waba' && empty($t->meta_template_id); $dot = $notSubmitted ? 'bg-paper-300' : ($statusDot[$t->status] ?? 'bg-paper-300'); // First 5 paragraphs of the body. Body is encrypted text; // we just split on \n\n so the card preview matches what // the operator typed. $bodyHtml = collect(explode("\n\n", (string) $t->template_body)) ->take(5) ->map(fn($p) => '

' . nl2br(e($p)) . '

') ->implode(''); // Which engine this template belongs to — shown as a chip on the card. $engKey = $t->engineKey(); $engMeta = [ 'baileys' => [__('Unofficial'), 'bg-wa-mint text-wa-deep'], 'waba' => [__('Meta WABA'), 'bg-wa-bubble text-wa-deep'], 'twilio' => [__('Twilio'), 'bg-[#F22F46]/10 text-[#A12534]'], 'instagram' => [__('Instagram'), 'bg-[#E1306C]/10 text-[#C13584]'], 'facebook' => [__('Facebook'), 'bg-[#1877F2]/10 text-[#1877F2]'], ][$engKey] ?? [__('Unofficial'), 'bg-paper-50 text-ink-700']; $isIg = $engKey === 'instagram'; $isFb = $engKey === 'facebook'; @endphp
{{ $t->template_name }} {{ ucfirst($catKey) }}
@if ($isIg) @elseif ($isFb) @else @endif{{ $engMeta[0] }} {{ $t->status_label }} · {{ ucfirst($t->template_type) }} @if ($t->meta_category) · {{ ucfirst($t->meta_category) }} @endif @if ($engKey === 'waba' && $t->provider && $t->provider->id) {{-- Which WABA account this template belongs to — so 3-account workspaces can tell their synced templates apart. --}} · {{ $t->provider->display_label ?: $t->provider->phone_number ?: 'WABA' }} @endif {{-- Per-message cost — only when this workspace is actually billed per message (pay-per-message / BSP). In classic plan mode sends are covered by the plan quota, so a "/msg" price here is misleading. --}} @if (in_array($engKey, ['waba', 'baileys', 'twilio'], true) && \App\Services\MessageBillingService::payPerMessageFor(auth()->user()?->currentWorkspace)) @php $__cost = \App\Services\MessageCreditRate::displayForCategory($t->effectiveCategory()); @endphp · @if ($__cost['free']){{ __('Free') }}@else{!! \App\Support\FormatSettings::display($__cost['minor'] / 100) !!}/{{ __('msg') }}@endif @endif
@php $btns = is_array($t->buttons) ? $t->buttons : []; $att = strtolower((string) $t->attachment_type); $hasMedia = in_array($att, ['image', 'video', 'document', 'media', 'location'], true); // WhatsApp-style formatting for the preview bubble: *bold*, _italic_, // ~strike~; and highlight {{variables}} as pills. Escape first. $fmt = e((string) $t->template_body); $fmt = preg_replace('/\*(.+?)\*/s', '$1', $fmt); $fmt = preg_replace('/_(.+?)_/s', '$1', $fmt); $fmt = preg_replace('/~(.+?)~/s', '$1', $fmt); $fmt = preg_replace('/\{\{\s*([^{}]+?)\s*\}\}/', '{{$1}}', $fmt); $fmt = nl2br($fmt); @endphp {{-- ===== WhatsApp message mockup ===== --}}
@if ($hasMedia)
@if ($att === 'video') @elseif ($att === 'document') @elseif ($att === 'location') @else @endif
@endif @if (!empty($t->header) && !$hasMedia)
{{ \Illuminate\Support\Str::limit($t->header, 90) }}
@endif
{!! $fmt !!}
@if (!empty($t->footer))
{{ \Illuminate\Support\Str::limit($t->footer, 120) }}
@endif
10:30
@if (count($btns))
@foreach (array_slice($btns, 0, 3) as $b)
@if (($b['type'] ?? '') === 'URL' || !empty($b['url'])) @elseif (($b['type'] ?? '') === 'PHONE_NUMBER' || !empty($b['phone_number'])) @else @endif {{ $b['text'] ?? __('Button') }}
@endforeach @if (count($btns) > 3)
+{{ count($btns) - 3 }} {{ __('more') }}
@endif
@endif
@if ($t->status === 'rejected' && $t->rejection_reason)
Rejected: {{ $t->rejection_reason }}
@endif
Edit template {{-- View = open the template detail / Meta review-status page (user.templates.show → /templates/{id}). Was missing, so a pending "In review" template had no way to check its status. --}}
@empty {{-- "Create template" opens the WhatsApp/Instagram + format modal (same as the header button) instead of jumping straight to the create form, so the channel step is never skipped. actionButtonAttrs renders a