1 | <?php |
||||||
2 | |||||||
3 | namespace App\Http\Controllers; |
||||||
4 | |||||||
5 | use Illuminate\Support\Facades\Auth; |
||||||
6 | use Illuminate\Support\Facades\Lang; |
||||||
7 | use Illuminate\Http\Request; |
||||||
8 | use App\Http\Controllers\Controller; |
||||||
9 | use App\Http\Requests\UpdateManagerProfileRequest; |
||||||
10 | use App\Models\JobPoster; |
||||||
11 | use App\Models\Lookup\Frequency; |
||||||
12 | use App\Models\Lookup\Department; |
||||||
13 | use App\Models\Manager; |
||||||
14 | use App\Services\Validation\Rules\LinkedInUrlRule; |
||||||
15 | use App\Services\Validation\Rules\TwitterHandleRule; |
||||||
16 | use Facades\App\Services\WhichPortal; |
||||||
17 | use Illuminate\Support\Facades\Hash; |
||||||
18 | |||||||
19 | class ManagerProfileController extends Controller |
||||||
20 | { |
||||||
21 | |||||||
22 | /** |
||||||
23 | * Show a manager profile |
||||||
24 | * |
||||||
25 | * @param \Illuminate\Http\Request $request Incoming Request. |
||||||
26 | * @param \App\Models\JobPoster $jobPoster Incoming JobPoster object. |
||||||
27 | |||||||
28 | * @return \Illuminate\Http\Response |
||||||
29 | */ |
||||||
30 | public function show(Request $request, JobPoster $jobPoster) |
||||||
31 | { |
||||||
32 | $manager = $jobPoster->manager; |
||||||
33 | $manager_profile = Lang::get('applicant/manager_profile'); |
||||||
34 | $manager_profile_sections = [ |
||||||
35 | [ |
||||||
36 | 'title' => $manager_profile['section_titles']['approach'], |
||||||
37 | 'questions' => [ |
||||||
38 | [ |
||||||
39 | 'title' => $manager_profile['questions']['leadership_style'], |
||||||
40 | 'answer' => $manager->leadership_style |
||||||
41 | ], |
||||||
42 | [ |
||||||
43 | 'title' => $manager_profile['questions']['employee_expectations'], |
||||||
44 | 'answer' => $manager->expectations |
||||||
45 | ], |
||||||
46 | [ |
||||||
47 | 'title' => $manager_profile['questions']['employee_learning'], |
||||||
48 | 'answer' => $manager->employee_learning |
||||||
49 | ] |
||||||
50 | ] |
||||||
51 | ], |
||||||
52 | [ |
||||||
53 | 'title' => $manager_profile['section_titles']['about_me'], |
||||||
54 | 'questions' => [ |
||||||
55 | [ |
||||||
56 | 'title' => $manager_profile['questions']['career_journey'], |
||||||
57 | 'answer' => $manager->career_journey |
||||||
58 | ], |
||||||
59 | [ |
||||||
60 | 'title' => $manager_profile['questions']['learning_path'], |
||||||
61 | 'answer' => $manager->learning_path |
||||||
62 | ], |
||||||
63 | [ |
||||||
64 | 'title' => $manager_profile['questions']['about_me'], |
||||||
65 | 'answer' => $manager->about_me |
||||||
66 | ] |
||||||
67 | ] |
||||||
68 | ] |
||||||
69 | ]; |
||||||
70 | |||||||
71 | $custom_breadcrumbs = [ |
||||||
72 | 'home' => route('home'), |
||||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||||
73 | 'jobs' => route(WhichPortal::prefixRoute('jobs.index')), |
||||||
74 | $jobPoster->title => route(WhichPortal::prefixRoute('jobs.summary'), $jobPoster), |
||||||
75 | 'profile' => '', |
||||||
76 | ]; |
||||||
77 | |||||||
78 | return view('applicant/manager', [ |
||||||
0 ignored issues
–
show
The function
view was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
79 | 'manager_profile' => $manager_profile, |
||||||
80 | 'urls' => Lang::get('common/urls'), |
||||||
81 | 'manager' => $manager, |
||||||
82 | 'manager_profile_photo_url' => '/images/user.png', // TODO get real photo. |
||||||
83 | 'manager_profile_sections' => $manager_profile_sections, |
||||||
84 | 'noInfo' => $manager_profile['no_info'], |
||||||
85 | 'custom_breadcrumbs' => $custom_breadcrumbs |
||||||
86 | ]); |
||||||
87 | } |
||||||
88 | |||||||
89 | /** |
||||||
90 | * Show the form for editing the logged-in manager's profile |
||||||
91 | * |
||||||
92 | * @param \Illuminate\Http\Request $request Incoming Request. |
||||||
93 | * @return \Illuminate\Http\Response |
||||||
94 | */ |
||||||
95 | public function editAuthenticated(Request $request) |
||||||
96 | { |
||||||
97 | $manager = $request->user()->manager; |
||||||
98 | return redirect(route('manager.profile.edit', $manager)); |
||||||
0 ignored issues
–
show
The function
redirect was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() The function
route was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
99 | } |
||||||
100 | |||||||
101 | /** |
||||||
102 | * Show the form for editing the logged-in user's manager profile |
||||||
103 | * |
||||||
104 | * @param \Illuminate\Http\Request $request Incoming Request. |
||||||
105 | * @param \App\Models\Manager $manager Incoming Manager. |
||||||
106 | * @return \Illuminate\Http\Response |
||||||
107 | */ |
||||||
108 | public function edit(Request $request, Manager $manager) |
||||||
109 | { |
||||||
110 | $manager_profile = Lang::get('manager/profile'); |
||||||
111 | // TODO: Improve workplace photos, and reference them in template direction from WorkEnvironment model. |
||||||
112 | $workplacePhotos = []; |
||||||
113 | |||||||
114 | $frequencies = Frequency::all(); |
||||||
115 | $linkedInUrlPattern = LinkedInUrlRule::PATTERN; |
||||||
116 | $twitterHandlePattern = TwitterHandleRule::PATTERN; |
||||||
117 | |||||||
118 | $custom_breadcrumbs = [ |
||||||
119 | 'home' => route('home'), |
||||||
0 ignored issues
–
show
The function
route was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
120 | 'profile' => '' |
||||||
121 | ]; |
||||||
122 | |||||||
123 | return view('manager/profile', [ |
||||||
0 ignored issues
–
show
The function
view was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
124 | // Localization. |
||||||
125 | 'profile_l10n' => $manager_profile, |
||||||
126 | // Data. |
||||||
127 | 'urls' => Lang::get('common/urls'), |
||||||
128 | 'user' => $manager->user, |
||||||
129 | 'manager' => $manager, |
||||||
130 | 'manager_profile_photo_url' => '/images/user.png', // TODO get real photo. |
||||||
131 | 'workplace_photos' => $workplacePhotos, |
||||||
132 | 'departments' => Department::all(), |
||||||
133 | 'telework_options' => $frequencies, |
||||||
134 | 'flex_hour_options' => $frequencies, |
||||||
135 | 'radio_options' => $frequencies, |
||||||
136 | 'translations' => $manager->getTranslations(), |
||||||
137 | 'linkedInUrlPattern' => $linkedInUrlPattern, |
||||||
138 | 'twitterHandlePattern' => $twitterHandlePattern, |
||||||
139 | 'custom_breadcrumbs' => $custom_breadcrumbs |
||||||
140 | ]); |
||||||
141 | } |
||||||
142 | |||||||
143 | /** |
||||||
144 | * Update the specified resource in storage. |
||||||
145 | * |
||||||
146 | * @param \Illuminate\Http\UpdateManagerProfileRequest $request Incoming Request. |
||||||
147 | * @param \App\Models\Manager $manager Incoming Manager. |
||||||
148 | * @return \Illuminate\Http\Response |
||||||
149 | */ |
||||||
150 | public function update(UpdateManagerProfileRequest $request, Manager $manager) |
||||||
151 | { |
||||||
152 | // TODO: save workplace Photos. |
||||||
153 | // TODO: remove control of name in production. |
||||||
154 | $input = $request->input(); |
||||||
155 | |||||||
156 | $validated = $request->validated(); |
||||||
157 | |||||||
158 | $user = $manager->user; |
||||||
159 | $user->fill($validated); |
||||||
160 | if (!empty($input['new_password'])) { |
||||||
161 | $user->password = Hash::make($input['new_password']); |
||||||
162 | } |
||||||
163 | $user->save(); |
||||||
164 | |||||||
165 | $manager->fill($validated); |
||||||
166 | $manager->save(); |
||||||
167 | |||||||
168 | // Use the button that was clicked to decide which element to redirect to. |
||||||
169 | switch ($input['submit']) { |
||||||
170 | case 'about_me': |
||||||
171 | $hash = '#managerProfileSectionAbout'; |
||||||
172 | break; |
||||||
173 | case 'leadership': |
||||||
174 | $hash = '#managerProfileSectionLeadership'; |
||||||
175 | break; |
||||||
176 | default: |
||||||
177 | $hash = ''; |
||||||
178 | break; |
||||||
179 | } |
||||||
180 | |||||||
181 | return redirect(route('manager.profile.edit', $manager) . $hash); |
||||||
0 ignored issues
–
show
The function
redirect was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() The function
route was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
182 | } |
||||||
183 | |||||||
184 | public function faq(Request $request) |
||||||
185 | { |
||||||
186 | $show_demo_notification = $request->user() && $request->user()->isDemoManager(); |
||||||
187 | |||||||
188 | return view( |
||||||
0 ignored issues
–
show
The function
view was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
189 | 'applicant/static_faq', |
||||||
190 | [ |
||||||
191 | 'breadcrumb_home' => route('manager.home'), |
||||||
0 ignored issues
–
show
The function
route was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
192 | 'faq' => Lang::get('applicant/faq'), |
||||||
193 | 'manager_sidebar_active' => 'active', |
||||||
194 | 'show_demo_notification' => $show_demo_notification, |
||||||
195 | ] |
||||||
196 | ); |
||||||
197 | } |
||||||
198 | } |
||||||
199 |