Commit 4343122d authored by Mahmoud Aglan's avatar Mahmoud Aglan

Add registration open/close toggle + fix event slug generation for Arabic titles

- Add openRegistration() and closeRegistration() methods to EventShow Livewire component
- Add registration control panel in event admin sidebar with status indicator and toggle buttons
- Fix slug generation to produce ASCII-safe slugs (prevents WhatsApp/messaging apps from
  truncating URLs containing Arabic/Hindi numerals)
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 5c809e27
......@@ -90,7 +90,8 @@ public function duplicate(Event $event, User $actor): Event
public function generateSlug(string $title, int $academyId, ?int $excludeId = null): string
{
$base = Str::slug($title, '-', null) ?: Str::random(8);
$ascii = Str::slug($title, '-', 'en');
$base = preg_match('/[a-z0-9]/', $ascii) ? $ascii : ('event-' . strtolower(Str::random(8)));
$slug = $base;
$counter = 1;
......
......@@ -49,6 +49,25 @@ public function publish(EventService $service): void
}
}
public function openRegistration(): void
{
$this->authorize('events.manage');
$this->event->update(['registration_closes_at' => null]);
if ($this->event->registration_opens_at && $this->event->registration_opens_at->isFuture()) {
$this->event->update(['registration_opens_at' => now()]);
}
$this->event->refresh();
session()->flash('success', __('تم فتح التسجيل'));
}
public function closeRegistration(): void
{
$this->authorize('events.manage');
$this->event->update(['registration_closes_at' => now()]);
$this->event->refresh();
session()->flash('success', __('تم إغلاق التسجيل'));
}
public function deleteEvent(EventService $service): void
{
$this->authorize('events.manage');
......
......@@ -193,6 +193,42 @@ class="w-full px-3 py-2 text-start text-sm rounded-lg border hover:bg-gray-50 tr
</div>
@endcan
{{-- Registration Control --}}
@can('events.manage')
@if(!in_array($event->status, [\App\Domain\Event\Enums\EventStatus::Draft, \App\Domain\Event\Enums\EventStatus::Cancelled]))
<div class="bg-white rounded-xl border border-gray-200 p-6">
<h3 class="text-sm font-semibold text-gray-700 mb-3">{{ __('التحكم بالتسجيل') }}</h3>
<div class="flex items-center gap-2 mb-3">
<span class="w-2.5 h-2.5 rounded-full {{ $event->isRegistrationOpen() ? 'bg-green-500' : 'bg-red-500' }}"></span>
<span class="text-sm {{ $event->isRegistrationOpen() ? 'text-green-700' : 'text-red-700' }}">
{{ $event->isRegistrationOpen() ? __('التسجيل مفتوح') : __('التسجيل مغلق') }}
</span>
</div>
<div class="space-y-2">
@if($event->isRegistrationOpen())
<button wire:click="closeRegistration"
wire:loading.attr="disabled"
wire:confirm="{{ __('هل أنت متأكد من إغلاق التسجيل؟') }}"
class="w-full px-3 py-2 bg-red-600 text-white text-sm rounded-lg hover:bg-red-700 transition-colors">
<span wire:loading.remove wire:target="closeRegistration">{{ __('إغلاق التسجيل') }}</span>
<span wire:loading wire:target="closeRegistration">{{ __('جارٍ...') }}</span>
</button>
@else
<button wire:click="openRegistration"
wire:loading.attr="disabled"
class="w-full px-3 py-2 bg-green-600 text-white text-sm rounded-lg hover:bg-green-700 transition-colors">
<span wire:loading.remove wire:target="openRegistration">{{ __('فتح التسجيل') }}</span>
<span wire:loading wire:target="openRegistration">{{ __('جارٍ...') }}</span>
</button>
@endif
</div>
@if($event->registration_closes_at)
<p class="text-xs text-gray-400 mt-2">{{ __('مغلق حتى:') }} {{ $event->registration_closes_at->translatedFormat('d M Y - H:i') }}</p>
@endif
</div>
@endif
@endcan
{{-- Form Fields Summary --}}
<div class="bg-white rounded-xl border border-gray-200 p-6">
<h3 class="text-sm font-semibold text-gray-700 mb-3">{{ __('حقول النموذج') }}</h3>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment