<?php

namespace Database\Seeders;

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

class ExternalEngagementsTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $activities = [
            'Guest Lecture', 
            'Workshop Facilitator', 
            'Conference Speaker', 
            'Panel Discussion Member', 
            'Industry Training Program',
            'Research Collaboration Meet',
            'Technical Seminar'
        ];

        $activityDescriptions = [
            'Conducted an advanced session on emerging AI trends.',
            'Facilitated a two-day workshop on cybersecurity practices.',
            'Spoke on innovations in renewable energy.',
            'Participated in a panel discussion on education reform.',
            'Provided industrial training on IoT devices.',
            'Collaborated on a research project in machine learning.',
            'Delivered a seminar on blockchain technology.'
        ];

        $invitingOrganizations = [
            'Indian Institute of Technology', 
            'National Institute of Technology', 
            'Infosys Ltd.', 
            'Tata Consultancy Services', 
            'Microsoft Research',
            'ISRO',
            'Bharat Electronics Limited'
        ];

        // Number of records to seed
        $numberOfRecords = 10;

        for ($i = 1; $i <= $numberOfRecords; $i++) {
            // Generate random start and end dates
            $startDate = Carbon::now()->subMonths(rand(1, 24))->subDays(rand(0, 30));
            $endDate = (clone $startDate)->addDays(rand(1, 5)); // 1 to 5 days later
            $numDays = $startDate->diffInDays($endDate) + 1; // Including start day

            ExternalEngagement::create([
                'faculty_id' => rand(1, 5),
                'department_id' => rand(1, 5),
                'activity' => $activities[array_rand($activities)],
                'activity_description' => $activityDescriptions[array_rand($activityDescriptions)],
                'inviting_organization' => $invitingOrganizations[array_rand($invitingOrganizations)],
                'start_date' => $startDate->format('Y-m-d'),
                'end_date' => $endDate->format('Y-m-d'),
                'num_days' => $numDays,
                'proof' => null, // Proof left null for now
            ]);
        }
    }
}
