Commit a4e6d437 authored by Mahmoud Aglan's avatar Mahmoud Aglan

Allow event deletion from any status + default website is_published to true

- Remove draft-only restriction on delete button in EventShow
- EventService::delete() no longer blocks deletion based on status
- Migration sets website_settings.is_published default to true and updates existing rows
- Fixes 404 on public event pages caused by unpublished website settings
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent ce5c6e89
......@@ -72,10 +72,6 @@ public function changeStatus(Event $event, EventStatus $newStatus, User $actor):
public function delete(Event $event): void
{
if ($event->registrations_count > 0 && $event->status !== EventStatus::Draft) {
throw new DomainException('لا يمكن حذف حدث به تسجيلات. قم بإلغائه بدلاً من ذلك.');
}
$event->delete();
}
......
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
DB::statement("ALTER TABLE website_settings ALTER COLUMN is_published SET DEFAULT true");
DB::table('website_settings')->where('is_published', false)->update(['is_published' => true]);
}
public function down(): void
{
DB::statement("ALTER TABLE website_settings ALTER COLUMN is_published SET DEFAULT false");
}
};
......@@ -213,16 +213,14 @@ class="w-full px-3 py-2 text-start text-sm rounded-lg border hover:bg-gray-50 tr
{{-- Danger Zone --}}
@can('events.manage')
@if($event->status === \App\Domain\Event\Enums\EventStatus::Draft)
<div class="bg-red-50 rounded-xl border border-red-200 p-6">
<h3 class="text-sm font-semibold text-red-700 mb-3">{{ __('منطقة الخطر') }}</h3>
<button wire:click="deleteEvent"
wire:confirm="{{ __('هل أنت متأكد من حذف هذا الحدث؟') }}"
class="w-full px-3 py-2 bg-red-600 text-white text-sm rounded-lg hover:bg-red-700 transition-colors">
{{ __('حذف الحدث') }}
</button>
</div>
@endif
<div class="bg-red-50 rounded-xl border border-red-200 p-6">
<h3 class="text-sm font-semibold text-red-700 mb-3">{{ __('منطقة الخطر') }}</h3>
<button wire:click="deleteEvent"
wire:confirm="{{ __('هل أنت متأكد من حذف هذا الحدث؟ لا يمكن التراجع عن هذا الإجراء.') }}"
class="w-full px-3 py-2 bg-red-600 text-white text-sm rounded-lg hover:bg-red-700 transition-colors">
{{ __('حذف الحدث') }}
</button>
</div>
@endcan
</div>
</div>
......
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