@extends('admin.layouts.app') @section('title', ($isEdit ? __('admin.campaign_groups.edit_title') : __('admin.campaign_groups.create_title')) . ' — ' . __('admin.brand.name')) @section('page_title', __('admin.campaign_groups.title')) @php $action = $isEdit ? route('admin.campaign-groups.update', $group) : route('admin.campaign-groups.store'); $initialFilters = old('filters') ? json_decode(old('filters'), true) : ($group->filters ?: ['type' => 'group', 'logic' => 'and', 'children' => []]); @endphp @push('styles') @endpush @section('content') @include('admin.partials.flash')
@csrf @if ($isEdit) @method('PUT') @endif {{-- The tree travels as one JSON string so arbitrary nesting survives a normal form POST; the server re-decodes and re-validates it. --}} @if ($errors->any())
    @foreach ($errors->all() as $error)
  • {{ $error }}
  • @endforeach
@endif {{-- ONE card, three stacked sections separated by rules. Each section is full-width: the rule builder needs the whole row — squeezing it beside the preview cost it the horizontal space its nested condition rows actually need. The preview now sits UNDER the rules, which also gives its recipient table a much wider run. --}}
{{-- ── 1 · Audience type ─────────────────────────────────── First because it decides everything else: the whole field registry, the option lists, and which conditions can even exist. One decision, then straight into the rules. --}}

2 {{ __('admin.campaign_groups.source.label') }} & {{ __('admin.campaign_groups.audience.label') }}

{{ __('admin.campaign_groups.source.help') }}

@error('entity_type')

{{ $message }}

@enderror

{{ __('admin.campaign_groups.audience.help') }}

{{-- ── 2 · Audience rules (full row) ──────────────────────── --}}

4 {{ __('admin.campaign_groups.sections.filters') }}

@include('admin.campaign-groups.partials.group-node', [ 'depth' => 1, 'maxDepth' => $metadata['limits']['max_depth'], 'node' => 'tree', 'parent' => null, 'index' => null, ])
{{-- ── Preview — full width, directly under the rules ─────── --}}

5{{ __('admin.campaign_groups.sections.preview') }}

{{ __('admin.campaign_groups.preview.count') }}

{{ __('admin.campaign_groups.preview.live_note') }}

{{-- ── 3 · Naming ────────────────────────────────────────── Last on purpose. You name a thing once you know what it is, and by here the audience it matches is already on screen. --}}

1 {{ __('admin.campaign_groups.sections.general') }}

@error('name_en')

{{ $message }}

@enderror
@error('name_ar')

{{ $message }}

@enderror

{{ __('admin.campaign_groups.form.name_help') }}

@if ($isEdit) {{-- Availability is only a meaningful choice on an EXISTING group: it withdraws it from the campaign picker without archiving it. A brand-new group is always available, so asking on create would be a question with one sane answer. --}}
@else {{-- Created available; no control, no ambiguity. --}} @endif
{{-- /.cg-sections --}}
{{-- /.card --}}
@endsection @push('scripts') @endpush