<?php

namespace Database\Seeders;

use App\Models\Event;
use Carbon\Carbon;
use Illuminate\Database\Seeder;

class EventSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        // Define the date range
        $startDate = Carbon::create(2025, 9, 1);
        $endDate = Carbon::create(2025, 10, 10);
        $daysDifference = $endDate->diffInDays($startDate);

        // Generate 50 events
        for ($i = 0; $i < 50; $i++) {
            // Calculate a date for each event, spreading them across the range
            $daysToAdd = (int) ($daysDifference / 49 * $i);
            $eventDate = $startDate->copy()->addDays($daysToAdd);

            Event::create([
                'date' => $eventDate->format('Y-m-d'),
                'image' => 'events/image_' . ($i + 1) . '.jpg',
                'title_en' => 'Event ' . ($i + 1) . ' - Annual Gathering',
                'title_ar' => 'حدث ' . ($i + 1) . ' - التجمع السنوي',
                'description_en' => 'This is the description for Event ' . ($i + 1) . ' held on ' . $eventDate->format('d/m/y') . '. Join us for an exciting gathering with various activities.',
                'description_ar' => 'هذا وصف الحدث ' . ($i + 1) . ' الذي سيعقد في ' . $eventDate->format('d/m/y') . '. انضم إلينا لتجمع مثير مع أنشطة متنوعة.',
            ]);
        }
    }
}
