| Conditions | 7 |
| Paths | 20 |
| Total Lines | 104 |
| Code Lines | 72 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 123 | public function update(Request $request, Manager $manager) { |
||
| 124 | $input = $request->input(); |
||
| 125 | |||
| 126 | //TODO: remove control of name in production |
||
| 127 | $manager->user->name = $input['name']; |
||
| 128 | $manager->user->save(); |
||
| 129 | |||
| 130 | $manager->fill([ |
||
| 131 | 'department_id' => $input['department'], |
||
| 132 | 'twitter_username' => $input['twitter_username'], |
||
| 133 | 'linkedin_url' => $input['linkedin_url'], |
||
| 134 | //'work_review_frequency_id' => [], |
||
| 135 | //'stay_late_frequency_id' => [], |
||
| 136 | //'engage_team_frequency_id' => [], |
||
| 137 | //'development_opportunity_frequency_id', |
||
| 138 | //'refuse_low_value_work_frequency_id', |
||
| 139 | 'years_experience' => $input['years_experience'], |
||
| 140 | 'en' => [ |
||
| 141 | 'about_me' => $input['about_me']['en'], |
||
| 142 | //'greatest_accomplishment', |
||
| 143 | 'branch' => $input['branch']['en'], |
||
| 144 | 'division' => $input['division']['en'], |
||
| 145 | 'position' => $input['position']['en'], |
||
| 146 | 'leadership_style' => $input['leadership_style']['en'], |
||
| 147 | 'employee_learning' => $input['employee_learning']['en'], |
||
| 148 | 'expectations' => $input['expectations']['en'], |
||
| 149 | 'education' => $input['education']['en'], |
||
| 150 | 'career_journey' => $input['career_journey']['en'], |
||
| 151 | 'learning_path' => $input['learning_path']['en'] |
||
| 152 | ], |
||
| 153 | 'fr' => [ |
||
| 154 | 'about_me' => $input['about_me']['fr'], |
||
| 155 | //'greatest_accomplishment', |
||
| 156 | 'branch' => $input['branch']['fr'], |
||
| 157 | 'division' => $input['division']['fr'], |
||
| 158 | 'position' => $input['position']['fr'], |
||
| 159 | 'leadership_style' => $input['leadership_style']['fr'], |
||
| 160 | 'employee_learning' => $input['employee_learning']['fr'], |
||
| 161 | 'expectations' => $input['expectations']['fr'], |
||
| 162 | 'education' => $input['education']['fr'], |
||
| 163 | 'career_journey' => $input['career_journey']['fr'], |
||
| 164 | 'learning_path' => $input['learning_path']['fr'] |
||
| 165 | ] |
||
| 166 | ]); |
||
| 167 | |||
| 168 | $manager->save(); |
||
| 169 | |||
| 170 | $work_environment = $manager->work_environment; |
||
| 171 | $work_environment->fill([ |
||
| 172 | 'en' => [ |
||
| 173 | 'things_to_know' => $input['things_to_know']['en'] |
||
| 174 | ], |
||
| 175 | 'fr' => [ |
||
| 176 | 'things_to_know' => $input['things_to_know']['fr'] |
||
| 177 | ] |
||
| 178 | ]); |
||
| 179 | //Slider select inputs can be missing from input if nothing was selected |
||
| 180 | if (isset($input['telework'])) { |
||
| 181 | $work_environment->telework_allowed_frequency_id = $input['telework']; |
||
| 182 | } |
||
| 183 | if (isset($input['flex_hours'])) { |
||
| 184 | $work_environment->flexible_hours_frequency_id = $input['flex_hours']; |
||
| 185 | } |
||
| 186 | $work_environment->save(); |
||
| 187 | |||
| 188 | $team_culture = $manager->team_culture; |
||
| 189 | $team_culture->fill([ |
||
| 190 | 'team_size' => $input['team_size'], |
||
| 191 | 'gc_directory_url' => $input['gc_directory_url'], |
||
| 192 | 'en' => [ |
||
| 193 | 'operating_context' => $input['operating_context']['en'], |
||
| 194 | 'what_we_value' => $input['what_we_value']['en'], |
||
| 195 | 'how_we_work' => $input['how_we_work']['en'] |
||
| 196 | ], |
||
| 197 | 'fr' => [ |
||
| 198 | 'operating_context' => $input['operating_context']['fr'], |
||
| 199 | 'what_we_value' => $input['what_we_value']['fr'], |
||
| 200 | 'how_we_work' => $input['how_we_work']['fr'] |
||
| 201 | ] |
||
| 202 | ]); |
||
| 203 | $team_culture->save(); |
||
| 204 | |||
| 205 | //TODO: save workplace Photos |
||
| 206 | |||
| 207 | //Use the button that was clicked to decide which element to redirect to |
||
| 208 | switch ($input['submit']) { |
||
| 209 | case 'about_me': |
||
| 210 | $hash = '#managerProfileSectionAbout'; |
||
| 211 | break; |
||
| 212 | case 'team_culture': |
||
| 213 | $hash = '#managerProfileSectionCulture'; |
||
| 214 | break; |
||
| 215 | case 'work_environment': |
||
| 216 | $hash = '#managerProfileSectionEnvrionment'; |
||
| 217 | break; |
||
| 218 | case 'leadership': |
||
| 219 | $hash = '#managerProfileSectionLeadership'; |
||
| 220 | break; |
||
| 221 | default: |
||
| 222 | $hash = ""; |
||
| 223 | break; |
||
| 224 | } |
||
| 225 | |||
| 226 | return redirect( route('manager.profile.edit', $manager).$hash ); |
||
|
1 ignored issue
–
show
|
|||
| 227 | } |
||
| 230 |