{{ $template?->exists ? 'Edit template' : 'Create template' }} Back @canany(['templates.create', 'templates.edit']) @endcanany @if(session('template_saved'))
{{ session('template_saved') }}
@endif @if(session('template_error'))
{{ session('template_error') }}
@endif @if(!empty($unknownAtSave))
Unknown placeholders detected: {{ implode(', ', $unknownAtSave) }}
These will render as empty strings for manual sends, and cause automatic triggers to fail and be logged.
@endif
{{-- LEFT: editor form --}}
Details
@error('name') {{ $message }} @enderror
Used by code-driven sends.
Filters placeholders + triggers.
Who this template is sent to.

Content
@if($channel === 'email')
{{-- Livewire binds to this hidden input; Trix pushes its HTML here on change --}} {{-- wire:ignore prevents Livewire from morphing the Trix DOM on re-renders --}}
@else
@if($smsLength !== null)
{{ $smsLength }} chars · {{ $smsSegments }} segment{{ $smsSegments === 1 ? '' : 's' }} · {{ $smsEncoding }} @if($smsSegments > 1) — will be sent as multiple parts @endif
@endif
@endif
{{-- Sender + flags --}}
Sender & flags
@if($channel === 'email')
If blank, falls back to the solicitor's general sender.
@else
@if($smsSenders->isEmpty()) No SMS senders are whitelisted yet. Add one under Solicitor → SMS Senders. @endif
@endif
{{-- Attachments --}}
Attachments

Select document types to automatically attach when this template is sent. The latest document of each type on the client will be used.

@if($documentTypes->isEmpty())
No document types configured.
@else
@foreach($documentTypes as $dt)
@endforeach
@endif @if(!empty($documentTypeIds))
@foreach($documentTypes->whereIn('id', array_map('intval', $documentTypeIds)) as $dt) {{ $dt->display_name }} @endforeach
@endif
{{-- Triggers section (only once the template exists) --}} @if($template?->exists)
Automatic triggers
@can('communications.triggers.manage') @endcan
@if(!$allow_automatic_send)
Enable "Usable by triggers" above to allow this template to fire automatically.
@endif @if($triggers->isEmpty())
No triggers configured.
@else @foreach($triggers as $trig) @endforeach
Event Applies to Condition Dedupe Active
{{ $trig->trigger_type->label() }} {{ $availableModels[$trig->model_type] ?? class_basename($trig->model_type ?? 'Any') }} @php $parts = []; $resolveNames = fn($ids, $map) => collect((array)$ids) ->map(fn($id) => $map[$id] ?? "#{$id}") ->implode(', '); if (!empty($trig->conditions['to_status_id'])) { $parts[] = 'To: ' . $resolveNames($trig->conditions['to_status_id'], $statusMap); } if (!empty($trig->conditions['from_status_id'])) { $parts[] = 'From: ' . $resolveNames($trig->conditions['from_status_id'], $statusMap); } if (!empty($trig->conditions['tag_id'])) { $parts[] = 'Tag: ' . $resolveNames($trig->conditions['tag_id'], $tagMap); } @endphp {{ implode(' · ', $parts) ?: '—' }} {{ $trig->dedupe_window_minutes }}m @if($trig->is_active) on @else off @endif @can('communications.triggers.manage') @endcan
@endif @if($showTriggerForm)
{{ $editingTriggerId ? 'Edit trigger' : 'New trigger' }}
{{-- Contextual condition builder --}}
@if($triggerForm['trigger_type'] === 'status_changed')

From status

@forelse($statuses as $s)
@empty No statuses configured. @endforelse

To status

@forelse($statuses as $s)
@empty No statuses configured. @endforelse
@elseif(in_array($triggerForm['trigger_type'], ['tag_added', 'tag_removed']))
@forelse($tags as $tag)
@empty No tags configured. @endforelse
@else

No conditions available for this trigger type.

@endif @if($triggerShowAdvancedConditions) @error('triggerForm.conditions') {{ $message }} @enderror Editing JSON directly overrides the checkboxes above when saving. @endif
@can('communications.triggers.manage') @endcan
@endif
@else
Save the template first to configure automatic triggers.
@endif
{{-- RIGHT: placeholders + preview --}}
Available placeholders click to insert
@foreach($placeholdersByPrefix as $prefix => $group)
{{ $prefix }}
@foreach($group as $p) @php $displayToken = '{' . '{ ' . $p->token . ' }' . '}'; @endphp
{{ $displayToken }} @if($p->description)
{{ $p->description }}
@endif
@if($channel === 'email') @else @endif
@endforeach
@endforeach @if($placeholdersByPrefix->isEmpty())
No placeholders registered.
@endif
Live preview
@if(!empty($previewUnknown))
Unknown placeholders: {{ implode(', ', $previewUnknown) }}
@endif @if($channel === 'email') @if($previewSubject)
Subject
{{ $previewSubject }}
@endif
{!! $previewBodyHtml ?: 'Start typing to see a preview...' !!}
@if($previewBodyText)
Plain text version
{{ $previewBodyText }}
@endif @else
{{ $previewBodyText ?: '—' }}
@if($smsLength !== null)
{{ $smsLength }} chars · {{ $smsSegments }} segment(s) · {{ $smsEncoding }}
@endif @endif @if(!empty($previewPlaceholdersUsed))
{{ count($previewPlaceholdersUsed) }} placeholder(s) resolved @foreach($previewPlaceholdersUsed as $token => $value) @endforeach
{{ $token }} {{ $value !== '' ? $value : '(empty)' }}
@endif
@once @endonce