subDays(rand(1, 30))->addHours(rand(0, 23))->addMinutes(rand(0, 59)); $endDate = (clone $startDate)->addDays(rand(0, 2))->addHours(rand(0, 23))->addMinutes(rand(0, 59)); // Determine if target audience is students or faculty $targetAudience = $targetAudiences[array_rand($targetAudiences)]; $studentYear = $targetAudience === 'Students' ? $studentYears[array_rand($studentYears)] : null; // Create the record IvOrganised::create([ 'faculty_id' => rand(1, 5), 'start_date' => $startDate->format('Y-m-d H:i:s'), 'end_date' => $endDate->format('Y-m-d H:i:s'), 'company_name' => $companyNames[array_rand($companyNames)], 'company_address' => $companyAddresses[array_rand($companyAddresses)], 'resource_person_name' => $resourcePersons[array_rand($resourcePersons)], 'resource_person_contact_details' => $contactDetails[array_rand($contactDetails)], 'target_audience' => $targetAudience, 'student_year' => $studentYear, 'number_of_participants' => rand(20, 100), 'objective' => $objectives[array_rand($objectives)], 'outcomes' => $outcomes[array_rand($outcomes)], 'department_id' => rand(1, 5), 'proof' => null, // Null for proof ]); } } }