blob: 3099dade9cc8e72b9d4297a9d89c5b51492af04e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
<?php
namespace Database\Seeders;
use App\Models\Admin;
use App\Models\Log;
use App\Models\Connection;
use App\Models\Skill;
use Illuminate\Database\Seeder;
use App\Models\Company;
use App\Models\Student;
use App\Models\Appointment;
// use Database\Seeders\AdminSeeder;
class DatabaseSeeder extends Seeder
{
public function run(): void
{
// Call the diploma seeder first
$this->call(DiplomaSeeder::class);
// Create skills
$this->call(SkillSeeder::class);
// Create entities
Student::factory()->count(20)->create();
Company::factory()->count(20)->create();
Appointment::factory()->count(20)->create();
Connection::factory()->count(20)->create();
Admin::factory()->count(20)->create();
Log::factory()->count(20)->create();
// Assign random skills to students
$skills = Skill::all();
Student::all()->each(function ($student) use ($skills) {
$student->skills()->attach(
$skills->random(rand(5, 15))->pluck('id')->toArray()
);
});
// Assign random skills to companies
Company::all()->each(function ($company) use ($skills) {
$company->skills()->attach(
$skills->random(rand(5, 20))->pluck('id')->toArray()
);
});
}
}
|