<?php

namespace Database\Seeders;

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

class ActivitiesAttendedResponsesTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        // Example data for random selection
        $titles = ['AI Workshop', 'Cloud Computing', 'Cybersecurity Basics', 'Data Analytics', 'Machine Learning', 'Blockchain Essentials'];
        $organizingInstitutes = ['Google', 'Microsoft', 'Amazon', 'IBM', 'Oracle'];
        $addresses = ['New York, USA', 'London, UK', 'Mumbai, India', 'Berlin, Germany', 'Tokyo, Japan'];
        $activityTypes = ['GL', 'IC', 'STTP'];
        $categories = ['Technical', 'Social', 'Entrepreneurial', 'Life Skill'];
        $levels = ['College', 'State', 'National', 'International'];

        // Number of responses to seed
        $numberOfResponses = 10;

        for ($i = 1; $i <= $numberOfResponses; $i++) {
            // Generate random start and end dates
            $startDate = Carbon::now()->subDays(rand(1, 30))->addHours(rand(0, 23))->addMinutes(rand(0, 59));
            $endDate = (clone $startDate)->addDays(rand(0, 3))->addHours(rand(0, 23))->addMinutes(rand(0, 59));
            $numDays = $startDate->diffInDays($endDate) ?: 1;

            // Create the response record
            ActivitiesAttended::create([
                'title' => $titles[array_rand($titles)], // Random title
                'organising_institute' => $organizingInstitutes[array_rand($organizingInstitutes)], // Random organization
                'address' => $addresses[array_rand($addresses)], // Random address
                'department_id' => rand(1, 5), // Random department ID
                'faculty_id' => rand(1, 5), // Random faculty ID
                'start_date' => $startDate->format('Y-m-d H:i:s'), // Start date and time
                'end_date' => $endDate->format('Y-m-d H:i:s'), // End date and time
                'num_days' => $numDays, // Number of days
                'activity_type' => $activityTypes[array_rand($activityTypes)], // Random activity type
                'category' => $categories[array_rand($categories)], // Random category
                'level' => $levels[array_rand($levels)], // Random level
                'proof' => null, // Null for proof
            ]);
        }
    }
}
