1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use App\Models\Applicant; |
4
|
|
|
use App\Models\HrAdvisor; |
5
|
|
|
use App\Models\JobApplication; |
6
|
|
|
use App\Models\JobPoster; |
7
|
|
|
use App\Models\Manager; |
8
|
|
|
use App\Models\User; |
9
|
|
|
use Illuminate\Database\Seeder; |
10
|
|
|
|
11
|
|
|
class StrategicResponseSeeder extends Seeder // phpcs:ignore |
12
|
|
|
{ |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Manager for Strategic Talent Response jobs. |
16
|
|
|
* |
17
|
|
|
* @var string |
18
|
|
|
*/ |
19
|
|
|
protected $strManagerEmail = '[email protected]'; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* HR Advisor for Strategic Talent Response jobs. |
23
|
|
|
* |
24
|
|
|
* @var string |
25
|
|
|
*/ |
26
|
|
|
protected $strHrEmail = '[email protected]'; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Run the database seeds. |
30
|
|
|
* |
31
|
|
|
* @return void |
32
|
|
|
*/ |
33
|
|
|
public function run(): void |
34
|
|
|
{ |
35
|
|
|
$str_department_id = config('app.strategic_response_department_id'); |
|
|
|
|
36
|
|
|
|
37
|
|
|
DB::table('departments')->updateOrInsert( |
38
|
|
|
['id' => $str_department_id], |
39
|
|
|
[ |
40
|
|
|
'name' => json_encode([ |
41
|
|
|
'en' => 'Strategic Talent Response', |
42
|
|
|
'fr' => 'Réponse stratégique de talents' |
43
|
|
|
]), |
44
|
|
|
'impact' => json_encode([ |
45
|
|
|
'en' => 'Impact text placeholder', |
46
|
|
|
'fr' => 'Impact text placeholder' |
47
|
|
|
]), |
48
|
|
|
'preference' => json_encode([ |
49
|
|
|
'en' => 'You must currently be an employee of the Government of Canada with valid security clearance to apply to this opportunity.', |
50
|
|
|
'fr' => 'Vous devez actuellement être un employé du gouvernement du Canada avec une habilitation de sécurité valide pour postuler à cette opportunité.' |
51
|
|
|
]), |
52
|
|
|
] |
53
|
|
|
); |
54
|
|
|
|
55
|
|
|
$hrUser = User::where('email', $this->strHrEmail)->first(); |
56
|
|
|
if ($hrUser === null) { |
57
|
|
|
$hrUser = factory(User::class)->state('hr_advisor')->create([ |
|
|
|
|
58
|
|
|
'email' => $this->strHrEmail, |
59
|
|
|
'department_id' => $str_department_id, |
60
|
|
|
]); |
61
|
|
|
$hrUser->hr_advisor()->save(factory(HrAdvisor::class)->create([ |
62
|
|
|
'user_id' => $hrUser->id, |
63
|
|
|
])); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
$managerUser = User::where('email', $this->strManagerEmail)->first(); |
67
|
|
|
// Create the test manager if it does not exist yet. |
68
|
|
|
if ($managerUser === null) { |
69
|
|
|
$managerUser = factory(User::class)->state('upgradedManager')->create([ |
70
|
|
|
'email' => $this->strManagerEmail, |
71
|
|
|
'department_id' => $str_department_id, |
72
|
|
|
]); |
73
|
|
|
$managerUser->manager()->save(factory(Manager::class)->create([ |
74
|
|
|
'user_id' => $managerUser->id, |
75
|
|
|
])); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
factory(JobPoster::class, 100)->states(['live', 'strategic_response'])->create([ |
79
|
|
|
'manager_id' => $managerUser->manager->id |
80
|
|
|
])->each(function ($job): void { |
81
|
|
|
$job->job_applications()->saveMany(factory(JobApplication::class, 5))->create([ |
|
|
|
|
82
|
|
|
'job_poster_id' => $job->id |
83
|
|
|
]); |
84
|
|
|
}); |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|