@extends('admin.layouts.app') @php $isEdit = $event->exists; // Admins type and read BUSINESS time (Asia/Riyadh); storage is UTC. The // request converts on the way in — this converts on the way back out, so // the value an admin sees in the field is the value they typed. $tz = \App\Support\Time\BookingsTimezone::business(); $startsValue = old('starts_at', $event->starts_at?->copy()->setTimezone($tz)->format('Y-m-d\TH:i')); $endsValue = old('ends_at', $event->ends_at?->copy()->setTimezone($tz)->format('Y-m-d\TH:i')); $chosen = collect(old('groups', $selectedGroups))->map(fn ($id) => (int) $id)->all(); @endphp @section('title', ($isEdit ? __('admin.events.edit') : __('admin.events.create')) . ' — ' . __('admin.brand.name')) @section('page_title', $isEdit ? __('admin.events.edit') : __('admin.events.create')) @push('styles') @endpush @section('content') @if ($isEdit) {{ __('admin.actions.view') }} @endif {{ __('admin.actions.back_to_list') }}
@csrf @if ($isEdit) @method('PUT') @endif
{{-- Start AND end are both required: the public flow fails closed on an incomplete range, so an event saved without an end would be permanently unreachable by investors. --}}

{{ __('admin.events.hints.timezone') }}

{{-- One or the other, never both. Requiring both taught admins to type filler into whichever field did not apply. --}}
{{-- Audience. Group membership IS eligibility for the public flow, so this is not decoration — it decides who can open the link at all. --}} {{-- `form-field` (not a bespoke class) so the label and the search input inherit the admin form styling every other field on this page uses. --}}
{{-- A legacy event predating the pivot targets nobody. Say so before the admin submits, rather than letting the first save fail on a bare "required". --}} @if ($isEdit && empty($chosen))

{{ __('admin.events.legacy_no_groups') }}

@endif
{{-- Selection summary sits above the picker so the answer to "who is this going to" is readable without scrolling the list. --}}
{{ __('admin.events.hints.no_groups_match') }}
{{-- The real submitted values, and they must stay INSIDE the x-data scope or Alpine never renders them and the form posts no groups at all. The checkboxes above are UI only, so the posted set always matches the chips regardless of search filtering. --}}
@error('groups') {{ $message }} @enderror @error('groups.*') {{ $message }} @enderror

{{ __('admin.events.hints.groups') }}

{{ __('admin.actions.cancel') }}
@endsection @push('scripts') @endpush