<?php

namespace Database\Seeders;

use App\Models\AdminUser;
use App\Models\Broadcast;
use App\Models\Event;
use Illuminate\Database\Seeder;

class BroadcastSeeder extends Seeder
{
    public function run(): void
    {
        $admin = AdminUser::first();
        if (! $admin) {
            return;
        }

        $event = Event::first();

        $broadcasts = [
            [
                'created_by_admin_id' => $admin->id,
                'title'               => 'Welcome to FH Mobile App!',
                'body'                => 'Assalamu Alaikum! Welcome to the Fayze Husainy Mobile App. Browse upcoming Umrah, Hajj, and Ziyarat packages and register with ease. May Allah accept your intentions.',
                'target'              => 'all',
                'event_id'            => null,
                'sent_at'             => now()->subDays(5),
            ],
            [
                'created_by_admin_id' => $admin->id,
                'title'               => 'Ramadan Umrah 2027 — Early Bird Open',
                'body'                => 'Alhamdulillah, early bird registrations are now open for our Ramadan Umrah 2027 package. Limited spots available. Book now to secure your place in this blessed journey.',
                'target'              => 'all',
                'event_id'            => null,
                'sent_at'             => now()->subDays(3),
            ],
            [
                'created_by_admin_id' => $admin->id,
                'title'               => 'Important: Document Submission Reminder',
                'body'                => 'Please ensure your passport and CNIC documents are uploaded in the app at least 30 days before departure. Incomplete documents may delay visa processing.',
                'target'              => 'all',
                'event_id'            => null,
                'sent_at'             => now()->subDay(),
            ],
            [
                'created_by_admin_id' => $admin->id,
                'title'               => 'Event Update: Departure Time Change',
                'body'                => 'Please note that the departure time for this event has been updated. Your new departure is scheduled for 03:00 AM. Please arrive at the airport 3 hours early.',
                'target'              => 'event',
                'event_id'            => $event?->id,
                'sent_at'             => now()->subHours(6),
            ],
        ];

        foreach ($broadcasts as $data) {
            Broadcast::firstOrCreate(
                ['title' => $data['title']],
                $data
            );
        }
    }
}
