| Conditions | 9 |
| Paths | 8 |
| Total Lines | 103 |
| Code Lines | 73 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 90 |
| 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 |
||
| 197 | public function store(Request $request) |
||
| 198 | { |
||
| 199 | |||
| 200 | $input = $request->input(); |
||
| 201 | |||
| 202 | $job = new JobPoster(); |
||
| 203 | $job->manager_id = $request->user()->manager->id; |
||
| 204 | $job->published = ($input['submit'] == 'publish'); |
||
| 205 | $job->fill([ |
||
| 206 | 'job_term_id' => JobTerm::where('name', 'month')->firstOrFail()->id, |
||
| 207 | 'term_qty' => $input['term_qty'], |
||
| 208 | 'open_date_time' => new Date($input['open_date'].$input['open_time']), |
||
| 209 | 'close_date_time' => new Date($input['close_date'].$input['close_time']), |
||
| 210 | 'start_date_time' => new Date($input['start_date_time']), |
||
| 211 | 'department_id' => $input['department'], |
||
| 212 | 'province_id' => $input['province'], |
||
| 213 | 'salary_min' => $input['salary_min'], |
||
| 214 | 'salary_max' => $input['salary_max'], |
||
| 215 | 'noc' => $input['noc'], |
||
| 216 | 'classification' => $input['classification'], |
||
| 217 | 'security_clearance_id' => $input['security_clearance'], |
||
| 218 | 'language_requirement_id' => $input['language_requirement'], |
||
| 219 | 'remote_work_allowed' => $request->input('remote_work_allowed', false), |
||
| 220 | 'en' => [ |
||
| 221 | 'city' => $input['city'], |
||
| 222 | 'title' => $input['title']['en'], |
||
| 223 | 'impact' => $input['impact']['en'], |
||
| 224 | 'branch' => $input['branch']['en'], |
||
| 225 | 'division' => $input['division']['en'], |
||
| 226 | 'education' => $input['education']['en'], |
||
| 227 | ], |
||
| 228 | 'fr' => [ |
||
| 229 | 'city' => $input['city'], |
||
| 230 | 'title' => $input['title']['fr'], |
||
| 231 | 'impact' => $input['impact']['fr'], |
||
| 232 | 'branch' => $input['branch']['fr'], |
||
| 233 | 'division' => $input['division']['fr'], |
||
| 234 | 'education' => $input['education']['fr'], |
||
| 235 | ], |
||
| 236 | ]); |
||
| 237 | $job->save(); |
||
| 238 | |||
| 239 | if (isset($input['task'])) { |
||
| 240 | foreach($input['task'] as $task) { |
||
| 241 | $jobPosterTask = new JobPosterKeyTask(); |
||
| 242 | $jobPosterTask->job_poster_id = $job->id; |
||
| 243 | $jobPosterTask->fill([ |
||
| 244 | 'en' => [ |
||
| 245 | 'description' => $task['en'] |
||
| 246 | ], |
||
| 247 | 'fr' => [ |
||
| 248 | 'description' => $task['fr'] |
||
| 249 | ] |
||
| 250 | ]); |
||
| 251 | $jobPosterTask->save(); |
||
| 252 | } |
||
| 253 | } |
||
| 254 | |||
| 255 | if (isset($input['question'])) { |
||
| 256 | foreach($input['question'] as $question) { |
||
| 257 | $jobQuestion = new JobPosterQuestion(); |
||
| 258 | $jobQuestion->job_poster_id = $job->id; |
||
| 259 | $jobQuestion->fill([ |
||
| 260 | 'en'=> [ |
||
| 261 | 'question' => $question['question']['en'], |
||
| 262 | 'description' => $question['description']['en'] |
||
| 263 | ], |
||
| 264 | 'fr'=> [ |
||
| 265 | 'question' => $question['question']['fr'], |
||
| 266 | 'description' => $question['description']['fr'] |
||
| 267 | ] |
||
| 268 | ]); |
||
| 269 | $jobQuestion->save(); |
||
| 270 | } |
||
| 271 | } |
||
| 272 | |||
| 273 | $criteria = $input['criteria']; |
||
| 274 | |||
| 275 | //Save new criteria |
||
| 276 | if (isset($criteria['new'])) { |
||
| 277 | foreach($criteria['new'] as $criteriaType => $criteriaTypeInput) { |
||
| 278 | foreach($criteriaTypeInput as $skillType => $skillTypeInput) { |
||
| 279 | foreach($skillTypeInput as $criteriaInput) { |
||
| 280 | $criteria = new Criteria(); |
||
| 281 | $criteria->job_poster_id = $job->id; |
||
| 282 | $criteria->fill([ |
||
| 283 | 'criteria_type_id' => CriteriaType::where('name', $criteriaType)->firstOrFail()->id, |
||
| 284 | 'skill_id' => $criteriaInput['skill_id'], |
||
| 285 | 'skill_level_id' => $criteriaInput['skill_level_id'], |
||
| 286 | 'en' => [ |
||
| 287 | 'description' => $criteriaInput['description']['en'], |
||
| 288 | ], |
||
| 289 | 'fr' => [ |
||
| 290 | 'description' => $criteriaInput['description']['fr'], |
||
| 291 | ], |
||
| 292 | ]); |
||
| 293 | $criteria->save(); |
||
| 294 | } |
||
| 295 | } |
||
| 296 | } |
||
| 297 | } |
||
| 298 | |||
| 299 | return redirect( route('manager.jobs.index') ); |
||
|
1 ignored issue
–
show
|
|||
| 300 | } |
||
| 302 |