Feat: Seeder for all tales

This commit is contained in:
Sallu9007
2025-03-24 03:31:38 +05:30
parent a20569c43a
commit 28aeeeb4c3
4 changed files with 159 additions and 1 deletions

View File

@@ -0,0 +1,73 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use App\Models\ActivitiesOrganised;
use Carbon\Carbon;
class ActivitiesOrganisedTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
// Example data for random selection
$titles = ['Web Development Workshop', 'AI and ML Seminar', 'IoT Bootcamp', 'Cybersecurity Conference', 'Big Data Analytics', 'Cloud Computing Masterclass'];
$resourcePersons = ['Dr. John Smith', 'Prof. Sarah Johnson', 'Dr. Michael Wong', 'Er. David Miller', 'Dr. Emily Chen'];
$organizations = ['Google', 'Microsoft', 'Amazon', 'IBM', 'Oracle', 'Meta', 'Apple'];
$targetAudiences = ['Faculty', 'Students', 'Both'];
$venues = ['Main Auditorium', 'Seminar Hall', 'Conference Room', 'Virtual Platform', 'Computer Lab'];
$activityTypes = ['Workshop', 'Seminar', 'Conference', 'Training Program', 'Hackathon'];
$categories = ['Technical', 'Social', 'Professional Development', 'Research', 'Industry Connect'];
$levels = ['Department', 'College', 'State', 'National', 'International'];
$objectives = [
'To enhance technical skills and knowledge in the field',
'To provide hands-on experience with industry tools',
'To bridge the gap between academia and industry',
'To promote research and innovation',
'To improve problem-solving capabilities'
];
$outcomes = [
'Participants gained practical knowledge and skills',
'Created awareness about emerging technologies',
'Enhanced industry-academia collaboration',
'Improved research capabilities among participants',
'Participants learned about latest industry trends'
];
// Number of records to seed
$numberOfRecords = 10;
for ($i = 1; $i <= $numberOfRecords; $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, 5))->addHours(rand(0, 23))->addMinutes(rand(0, 59));
$numDays = $startDate->diffInDays($endDate) + 1;
// Create the record
ActivitiesOrganised::create([
'title' => $titles[array_rand($titles)],
'resource_person_name' => $resourcePersons[array_rand($resourcePersons)],
'resource_person_organization' => $organizations[array_rand($organizations)],
'target_audience' => $targetAudiences[array_rand($targetAudiences)],
'number_of_participants' => rand(20, 200),
'objective' => $objectives[array_rand($objectives)],
'outcomes' => $outcomes[array_rand($outcomes)],
'department_id' => rand(1, 5),
'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'),
'num_days' => $numDays,
'venue' => $venues[array_rand($venues)],
'activity_type' => $activityTypes[array_rand($activityTypes)],
'category' => $categories[array_rand($categories)],
'level' => $levels[array_rand($levels)],
'proof' => null, // Null for proof
]);
}
}
}

View File

@@ -20,6 +20,8 @@ class DatabaseSeeder extends Seeder
DepartmentSeeder::class, DepartmentSeeder::class,
UsersTableSeeder::class, UsersTableSeeder::class,
ActivitiesAttendedResponsesTableSeeder::class, ActivitiesAttendedResponsesTableSeeder::class,
ActivitiesOrganisedTableSeeder::class,
IvOrganisedTableSeeder::class,
]); ]);
// User::factory()->create([ // User::factory()->create([

View File

@@ -0,0 +1,83 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use App\Models\IvOrganised;
use Carbon\Carbon;
class IvOrganisedTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
// Example data for random selection
$companyNames = ['Google', 'Microsoft', 'Amazon', 'IBM', 'Infosys', 'TCS', 'Wipro', 'Facebook', 'Tesla'];
$companyAddresses = [
'Bangalore Electronic City, Karnataka',
'Hyderabad Hitech City, Telangana',
'Pune IT Park, Maharashtra',
'Mumbai Bandra Kurla Complex, Maharashtra',
'NCR Noida, Uttar Pradesh'
];
$resourcePersons = ['Mr. Raj Kumar', 'Ms. Priya Singh', 'Dr. Anil Sharma', 'Er. Neha Patel', 'Mr. Vikram Mehta'];
$contactDetails = [
'raj.kumar@example.com | +91 9876543210',
'priya.singh@example.com | +91 8765432109',
'anil.sharma@example.com | +91 7654321098',
'neha.patel@example.com | +91 6543210987',
'vikram.mehta@example.com | +91 5432109876'
];
$targetAudiences = ['Faculty', 'Students'];
$studentYears = ['First Year', 'Second Year', 'Third Year', 'Final Year'];
$objectives = [
'To expose students to real-world industrial environments',
'To bridge the gap between theoretical and practical knowledge',
'To understand industrial processes and practices',
'To provide insights into current industry trends',
'To explore potential career opportunities and requirements'
];
$outcomes = [
'Students gained practical exposure to industrial processes',
'Enhanced understanding of theoretical concepts through practical demonstrations',
'Participants became aware of industry expectations and requirements',
'Improved industry-academia interaction',
'Students received guidance on career opportunities and skill requirements'
];
// Number of records to seed
$numberOfRecords = 10;
for ($i = 1; $i <= $numberOfRecords; $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, 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
]);
}
}
}

View File

@@ -17,7 +17,7 @@ class UsersTableSeeder extends Seeder
public function run() public function run()
{ {
// Number of users to seed // Number of users to seed
$numberOfUsers = 2; $numberOfUsers = 5;
for ($i = 1; $i <= $numberOfUsers; $i++) { for ($i = 1; $i <= $numberOfUsers; $i++) {
User::create([ User::create([