@php $isEdit = isset($template); $oldType = old('type', $template->type ?? 'sms'); $oldWhatsappType = old('whatsapp_type', $template->whatsapp_type ?? 'official'); $oldTitle = old('title', $template->title ?? ''); $oldMetaName = old('meta_name', $template->meta_name ?? ''); $oldLanguage = old('language', $template->language ?? 'en_US'); $oldCategory = old('category', $template->category ?? 'UTILITY'); $oldSubject = old('subject', $template->subject ?? ''); $oldContent = old('content', $template->content ?? ''); $existingExamples = []; $existingBtnUrlText = old('btn_url_text', ''); $existingBtnUrl = old('btn_url', ''); $existingBtnCallText = old('btn_call_text', ''); $existingBtnCallPhone = old('btn_call_phone', ''); if ($isEdit && !empty($template->components) && is_array($template->components)) { foreach ($template->components as $component) { if (($component['type'] ?? null) === 'BODY') { $bodyText = $component['example']['body_text'][0] ?? []; if (is_array($bodyText)) { foreach ($bodyText as $i => $val) { $existingExamples[$i + 1] = $val; } } } if (($component['type'] ?? null) === 'BUTTONS' && !empty($component['buttons']) && is_array($component['buttons'])) { foreach ($component['buttons'] as $btn) { if (($btn['type'] ?? null) === 'URL') { $existingBtnUrlText = old('btn_url_text', $btn['text'] ?? ''); $existingBtnUrl = old('btn_url', $btn['url'] ?? ''); } if (($btn['type'] ?? null) === 'PHONE_NUMBER') { $existingBtnCallText = old('btn_call_text', $btn['text'] ?? ''); $existingBtnCallPhone = old('btn_call_phone', $btn['phone_number'] ?? ''); } } } } } preg_match_all('/\{\{(\d+)\}\}/', $oldContent, $matches); $detectedVariables = collect($matches[1] ?? []) ->map(function ($v) { return (int) $v; }) ->unique() ->sort() ->values() ->all(); @endphp
@csrf @if($isEdit) @method('PUT') @endif

{{ $isEdit ? 'Edit Message Template' : 'Create Message Template' }}

@if($oldType === 'whatsapp') @if($oldWhatsappType === 'unofficial') Unofficial @else Official @endif Status: {{ $template->status ?? 'Draft' }} @endif
@if($errors->any())
Please fix the following issues:
    @foreach($errors->all() as $error)
  • {{ $error }}
  • @endforeach
@endif
Basic Information
{{-- WhatsApp Template Category Selector (Official vs Unofficial) --}}

Meta তে পাঠিয়ে approve করাতে হবে। Approved হওয়ার পর মেসেজ পাঠানো যাবে।

Approve এর জন্যে Meta তে submit করা লাগবে না। সরাসরি তৈরি ও ব্যবহার করা যাবে।

{{-- Official WhatsApp Settings (Meta) --}}
Meta WhatsApp Settings
Official Template: এই টেমপ্লেটটি Meta-তে সাবমিট করে অনুমোদনের (Approval) জন্য পাঠানো হবে।
শুধুমাত্র ছোট হাতের ইংরেজি অক্ষর, সংখ্যা এবং আন্ডারস্কোর (_)।
{{-- Unofficial WhatsApp Notice --}}
Unofficial WhatsApp Template

এই টেমপ্লেটটির জন্য Meta-র কোনো approval বা submission প্রয়োজন নেই। বডি লিখে সরাসরি সেভ করুন।

Email Settings
Content
Characters: 0
Variable Samples
@if(count($detectedVariables))
@foreach($detectedVariables as $variableNo)
Variable {{ $variableNo }}
{{{{ $variableNo }}}}
@endforeach
@else
No variables detected
@endif
Buttons
Back
Preview
{{ $oldContent ?: 'SMS preview...' }}
{{ $oldSubject ?: 'Email subject...' }}
{{ $oldContent ?: 'Email body preview...' }}
@if(count($detectedVariables)) @foreach($detectedVariables as $variableNo) {{{{ $variableNo }}}} @endforeach @else No variables detected @endif