1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Http\Controllers; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\Facades\Lang; |
6
|
|
|
use Illuminate\Http\Request; |
7
|
|
|
use App\Http\Controllers\Controller; |
8
|
|
|
use App\Models\Lookup\Frequency; |
9
|
|
|
use App\Models\Lookup\Department; |
10
|
|
|
use App\Models\WorkEnvironment; |
11
|
|
|
use App\Models\TeamCulture; |
12
|
|
|
use App\Models\Manager; |
13
|
|
|
|
14
|
|
|
class ManagerProfileController extends Controller { |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Show a manager profile |
18
|
|
|
* |
19
|
|
|
* @param Request $request |
|
|
|
|
20
|
|
|
* @param \App\Models\Manager $manager |
|
|
|
|
21
|
|
|
* @return \Illuminate\Http\Response |
22
|
|
|
*/ |
23
|
|
|
public function show(Request $request, Manager $manager) { |
|
|
|
|
24
|
|
|
$manager_profile = Lang::get('applicant/manager_profile'); |
25
|
|
|
|
26
|
|
|
$manager_profile_sections = [ |
27
|
|
|
[ |
28
|
|
|
"title" => $manager_profile['section_titles']['approach'], |
29
|
|
|
"questions" => [ |
30
|
|
|
[ |
31
|
|
|
"title" => $manager_profile['questions']['leadership_style'], |
32
|
|
|
"answer" => $manager->leadership_style |
33
|
|
|
], |
34
|
|
|
[ |
35
|
|
|
"title" => $manager_profile['questions']['employee_expectations'], |
36
|
|
|
"answer" => $manager->expectations |
37
|
|
|
], |
38
|
|
|
[ |
39
|
|
|
"title" => $manager_profile['questions']['employee_learning'], |
40
|
|
|
"answer" => $manager->employee_learning |
41
|
|
|
] |
42
|
|
|
] |
43
|
|
|
], |
44
|
|
|
[ |
45
|
|
|
"title" => $manager_profile['section_titles']['about_me'], |
46
|
|
|
"questions" => [ |
47
|
|
|
[ |
48
|
|
|
"title" => $manager_profile['questions']['career_journey'], |
49
|
|
|
"answer" => $manager->career_journey |
50
|
|
|
], |
51
|
|
|
[ |
52
|
|
|
"title" => $manager_profile['questions']['learning_path'], |
53
|
|
|
"answer" => $manager->learning_path |
54
|
|
|
], |
55
|
|
|
[ |
56
|
|
|
"title" => $manager_profile['questions']['about_me'], |
57
|
|
|
"answer" => $manager->about_me |
58
|
|
|
] |
59
|
|
|
] |
60
|
|
|
] |
61
|
|
|
]; |
62
|
|
|
|
63
|
|
|
|
64
|
|
|
return view('applicant/manager', [ |
|
|
|
|
65
|
|
|
"manager_profile" => $manager_profile, |
66
|
|
|
'urls' => Lang::get('common/urls'), |
67
|
|
|
'manager' => $manager, |
68
|
|
|
'manager_profile_photo_url' => '/images/user.png', //TODO get real photo |
69
|
|
|
"manager_profile_sections" => $manager_profile_sections, |
70
|
|
|
]); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Show the form for editing the logged-in manager's profile |
75
|
|
|
* |
76
|
|
|
* @param Request $request |
|
|
|
|
77
|
|
|
* @return \Illuminate\Http\RedirectResponse |
78
|
|
|
*/ |
79
|
|
|
public function editAuthenticated(Request $request): \Illuminate\Http\RedirectResponse |
80
|
|
|
{ |
81
|
|
|
$manager = $request->user()->manager; |
82
|
|
|
return redirect(route('manager.profile.edit', $manager)); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Show the form for editing the logged-in user's manager profile |
87
|
|
|
* |
88
|
|
|
* @param Request $request |
|
|
|
|
89
|
|
|
* @param \App\Models\Manager $manager |
|
|
|
|
90
|
|
|
* @return \Illuminate\Http\Response |
91
|
|
|
*/ |
92
|
|
|
public function edit(Request $request, Manager $manager) { |
|
|
|
|
93
|
|
|
|
94
|
|
|
//TODO: Improve workplace photos, and reference them in template direction from WorkEnvironment model |
95
|
|
|
$workplacePhotos = []; |
96
|
|
|
if ($manager->work_environment != null) { |
97
|
|
|
foreach($manager->work_environment->workplace_photo_captions as $photoCaption) { |
|
|
|
|
98
|
|
|
$workplacePhotos[] = [ |
99
|
|
|
'id' => $photoCaption->id, |
100
|
|
|
'alt' => $photoCaption->description, |
101
|
|
|
'alt_fr' => $photoCaption->description, |
102
|
|
|
'url' => '/images/user.png' |
103
|
|
|
]; |
104
|
|
|
} |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
$frequencies = Frequency::all(); |
108
|
|
|
|
109
|
|
|
return view('manager/profile', [ |
|
|
|
|
110
|
|
|
/* Localization */ |
111
|
|
|
'profile_l10n' => Lang::get('manager/profile'), |
112
|
|
|
|
113
|
|
|
/* Data */ |
114
|
|
|
'urls' => Lang::get('common/urls'), |
115
|
|
|
'user' => $manager->user, |
116
|
|
|
'manager' => $manager, |
117
|
|
|
'manager_profile_photo_url' => '/images/user.png', //TODO get real photo |
118
|
|
|
'team_culture' => $manager->team_culture, |
119
|
|
|
'work_environment' => $manager->work_environment, |
120
|
|
|
'workplace_photos' => $workplacePhotos, |
121
|
|
|
'departments' => Department::all(), |
122
|
|
|
'telework_options' => $frequencies, |
123
|
|
|
'flex_hour_options' => $frequencies, |
124
|
|
|
'radio_options' => $frequencies |
125
|
|
|
]); |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* Update the specified resource in storage. |
130
|
|
|
* |
131
|
|
|
* @param \Illuminate\Http\Request $request |
|
|
|
|
132
|
|
|
* @param \App\Models\Manager $manager |
|
|
|
|
133
|
|
|
* @return \Illuminate\Http\Response |
134
|
|
|
*/ |
135
|
|
|
public function update(Request $request, Manager $manager) { |
|
|
|
|
136
|
|
|
$input = $request->input(); |
137
|
|
|
|
138
|
|
|
//TODO: remove control of name in production |
139
|
|
|
$manager->user->name = $input['name']; |
140
|
|
|
$manager->user->save(); |
141
|
|
|
|
142
|
|
|
$manager->fill([ |
143
|
|
|
'department_id' => $input['department'], |
144
|
|
|
'twitter_username' => $input['twitter_username'], |
145
|
|
|
'linkedin_url' => $input['linkedin_url'], |
146
|
|
|
//'work_review_frequency_id' => [], |
147
|
|
|
//'stay_late_frequency_id' => [], |
148
|
|
|
//'engage_team_frequency_id' => [], |
149
|
|
|
//'development_opportunity_frequency_id', |
150
|
|
|
//'refuse_low_value_work_frequency_id', |
151
|
|
|
'years_experience' => $input['years_experience'], |
152
|
|
|
'en' => [ |
153
|
|
|
'about_me' => $input['about_me']['en'], |
154
|
|
|
//'greatest_accomplishment', |
155
|
|
|
'branch' => $input['branch']['en'], |
156
|
|
|
'division' => $input['division']['en'], |
157
|
|
|
'position' => $input['position']['en'], |
158
|
|
|
'leadership_style' => $input['leadership_style']['en'], |
159
|
|
|
'employee_learning' => $input['employee_learning']['en'], |
160
|
|
|
'expectations' => $input['expectations']['en'], |
161
|
|
|
'education' => $input['education']['en'], |
162
|
|
|
'career_journey' => $input['career_journey']['en'], |
163
|
|
|
'learning_path' => $input['learning_path']['en'] |
164
|
|
|
], |
165
|
|
|
'fr' => [ |
166
|
|
|
'about_me' => $input['about_me']['fr'], |
167
|
|
|
//'greatest_accomplishment', |
168
|
|
|
'branch' => $input['branch']['fr'], |
169
|
|
|
'division' => $input['division']['fr'], |
170
|
|
|
'position' => $input['position']['fr'], |
171
|
|
|
'leadership_style' => $input['leadership_style']['fr'], |
172
|
|
|
'employee_learning' => $input['employee_learning']['fr'], |
173
|
|
|
'expectations' => $input['expectations']['fr'], |
174
|
|
|
'education' => $input['education']['fr'], |
175
|
|
|
'career_journey' => $input['career_journey']['fr'], |
176
|
|
|
'learning_path' => $input['learning_path']['fr'] |
177
|
|
|
] |
178
|
|
|
]); |
179
|
|
|
|
180
|
|
|
$manager->save(); |
181
|
|
|
|
182
|
|
|
$work_environment = $manager->work_environment; |
183
|
|
|
$work_environment->fill([ |
184
|
|
|
'en' => [ |
185
|
|
|
'things_to_know' => $input['things_to_know']['en'] |
186
|
|
|
], |
187
|
|
|
'fr' => [ |
188
|
|
|
'things_to_know' => $input['things_to_know']['fr'] |
189
|
|
|
] |
190
|
|
|
]); |
191
|
|
|
//Slider select inputs can be missing from input if nothing was selected |
192
|
|
|
if (isset($input['telework'])) { |
193
|
|
|
$work_environment->telework_allowed_frequency_id = $input['telework']; |
194
|
|
|
} |
195
|
|
|
if (isset($input['flex_hours'])) { |
196
|
|
|
$work_environment->flexible_hours_frequency_id = $input['flex_hours']; |
197
|
|
|
} |
198
|
|
|
$work_environment->save(); |
199
|
|
|
|
200
|
|
|
$team_culture = $manager->team_culture; |
201
|
|
|
$team_culture->fill([ |
202
|
|
|
'team_size' => $input['team_size'], |
203
|
|
|
'gc_directory_url' => $input['gc_directory_url'], |
204
|
|
|
'en' => [ |
205
|
|
|
'operating_context' => $input['operating_context']['en'], |
206
|
|
|
'what_we_value' => $input['what_we_value']['en'], |
207
|
|
|
'how_we_work' => $input['how_we_work']['en'] |
208
|
|
|
], |
209
|
|
|
'fr' => [ |
210
|
|
|
'operating_context' => $input['operating_context']['fr'], |
211
|
|
|
'what_we_value' => $input['what_we_value']['fr'], |
212
|
|
|
'how_we_work' => $input['how_we_work']['fr'] |
213
|
|
|
] |
214
|
|
|
]); |
215
|
|
|
$team_culture->save(); |
216
|
|
|
|
217
|
|
|
//TODO: save workplace Photos |
218
|
|
|
|
219
|
|
|
//Use the button that was clicked to decide which element to redirect to |
220
|
|
|
switch ($input['submit']) { |
221
|
|
|
case 'about_me': |
222
|
|
|
$hash = '#managerProfileSectionAbout'; |
223
|
|
|
break; |
224
|
|
|
case 'team_culture': |
225
|
|
|
$hash = '#managerProfileSectionCulture'; |
226
|
|
|
break; |
227
|
|
|
case 'work_environment': |
228
|
|
|
$hash = '#managerProfileSectionEnvrionment'; |
229
|
|
|
break; |
230
|
|
|
case 'leadership': |
231
|
|
|
$hash = '#managerProfileSectionLeadership'; |
232
|
|
|
break; |
233
|
|
|
default: |
234
|
|
|
$hash = ""; |
235
|
|
|
break; |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
return redirect( route('manager.profile.edit', $manager).$hash ); |
|
|
|
|
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
} |
242
|
|
|
|