@php $blueprint = $blueprint ?? null; $mode = $mode ?? 'create'; $isEdit = $mode === 'edit' && $blueprint; $action = $isEdit ? route('admin.prebuilt-templates.update', $blueprint->id) : route('admin.prebuilt-templates.store'); $btns = old('buttons', $isEdit ? ($blueprint->buttons ?: []) : []); $btns = array_values(array_filter($btns, fn ($b) => is_array($b) && ($b['type'] ?? '') !== '')); $cats = ['marketing', 'utility', 'authentication']; $curType = old('template_type', $blueprint->template_type ?? 'standard'); $curType = in_array($curType, ['standard', 'media'], true) ? $curType : 'standard'; $curAttach = old('attachment_type', $blueprint->attachment_type ?? 'image'); $curAttach = in_array($curAttach, ['image', 'video', 'document'], true) ? $curAttach : 'image'; $mediaUrl = ($isEdit && $blueprint->attachment_file) ? media_url($blueprint->attachment_file) : ''; $btnTypes = ['quick_reply' => __('Quick reply'), 'url' => __('URL'), 'phone_number' => __('Phone')]; // Built in raw PHP (not inline in the Blade echo): a literal {{1}} inside a // {{ __() }} echo makes the Blade compiler choke ("Unclosed '(' ..."). $bodyPlaceholder = 'Type your message. Use {{1}} {{2}} for variables the tenant fills when sending.'; @endphp
{{ __('Admin') }} {{ __('Pre-built') }} {{ $isEdit ? __('Edit') : __('New') }}
{{ $curType === 'media' ? __('Media') : __('Standard') }} {{ __('Cancel') }}
{{ __('Admin · Templates · Pre-built library') }}

{{ $isEdit ? __('Edit') : __('New') }} {{ __('blueprint') }}

{{ __('A WhatsApp template blueprint. Tenants clone it into their own workspace and submit that copy to Meta — nothing here is sent to Meta.') }}

@if ($errors->any())
{{ __('Could not save the blueprint:') }}
    @foreach ($errors->all() as $msg)
  • {{ $msg }}
  • @endforeach
@endif
@csrf @if ($isEdit) @method('PUT') @endif
{{-- 01 Identity --}}
01 {{ __('Identity') }} {{ __('required') }}
{{ __('a-z, 0-9, _ only.') }}
{{ __('Determines Meta review path for the tenant.') }}
{{ __('One locale per template.') }}
{{ __('Standard') }} {{ __('Media header') }}
{{ __('Standard = text header or none. Media = image / video / document header.') }}
{{-- 02 Header --}}
02 {{ __('Header') }} {{ __('optional') }}
{{-- Standard: text header --}}
{{-- Media: type + sample file --}}
{{ $isEdit && $blueprint->attachment_file ? __('Sample stored — choose to replace') : __('Choose sample file') }}
{{ __('shown to tenants as the media example') }}
{{ __('Browse') }}
{{-- 03 Body --}}
03 {{ __('Body') }} {{ __('required') }} / 0/1024
B I S ‹› {{ __('Variable') }}
{{ __('Markdown:') }} *bold* _italic_ ~strike~ ```code``` · {{ __('variables') }} @{{ 1 }} @{{ 2 }}
{{-- 04 Footer --}}
04 {{ __('Footer') }} {{ __('optional / max 60') }}
{{ __('Plain text under the body. No variables.') }}
{{-- 05 Buttons --}}
05 {{ __('Buttons') }} {{ __('optional / up to 10') }}
@php $rows = count($btns) ? $btns : [['type' => '', 'text' => '', 'value' => '']]; @endphp @foreach ($rows as $i => $b) @php $bt = $b['type'] ?? ''; $showVal = in_array($bt, ['url', 'phone_number'], true); @endphp
@endforeach
{{-- Clone source for new rows (index __IDX__ swapped by JS). --}}
{{-- ===== PREVIEW ===== --}}