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