| Conditions | 9 |
| Paths | 8 |
| Total Lines | 102 |
| 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 |
||
| 158 | public function store(Request $request) { |
||
| 159 | |||
| 160 | $input = $request->input(); |
||
| 161 | |||
| 162 | $job = new JobPoster(); |
||
| 163 | $job->manager_id = $request->user()->manager->id; |
||
| 164 | $job->published = ($input['submit'] == 'publish'); |
||
| 165 | $job->fill([ |
||
| 166 | 'job_term_id' => JobTerm::where('name', 'month')->firstOrFail()->id, |
||
| 167 | 'term_qty' => $input['term_qty'], |
||
| 168 | 'open_date_time' => new Date($input['open_date'].$input['open_time']), |
||
| 169 | 'close_date_time' => new Date($input['close_date'].$input['close_time']), |
||
| 170 | 'start_date_time' => new Date($input['start_date_time']), |
||
| 171 | 'department_id' => $input['department'], |
||
| 172 | 'province_id' => $input['province'], |
||
| 173 | 'salary_min' => $input['salary_min'], |
||
| 174 | 'salary_max' => $input['salary_max'], |
||
| 175 | 'noc' => $input['noc'], |
||
| 176 | 'classification' => $input['classification'], |
||
| 177 | 'security_clearance_id' => $input['security_clearance'], |
||
| 178 | 'language_requirement_id' => $input['language_requirement'], |
||
| 179 | 'remote_work_allowed' => $request->input('remote_work_allowed', false), |
||
| 180 | 'en' => [ |
||
| 181 | 'city' => $input['city'], |
||
| 182 | 'title' => $input['title']['en'], |
||
| 183 | 'impact' => $input['impact']['en'], |
||
| 184 | 'branch' => $input['branch']['en'], |
||
| 185 | 'division' => $input['division']['en'], |
||
| 186 | 'education' => $input['education']['en'], |
||
| 187 | ], |
||
| 188 | 'fr' => [ |
||
| 189 | 'city' => $input['city'], |
||
| 190 | 'title' => $input['title']['fr'], |
||
| 191 | 'impact' => $input['impact']['fr'], |
||
| 192 | 'branch' => $input['branch']['fr'], |
||
| 193 | 'division' => $input['division']['fr'], |
||
| 194 | 'education' => $input['education']['fr'], |
||
| 195 | ], |
||
| 196 | ]); |
||
| 197 | $job->save(); |
||
| 198 | |||
| 199 | if (isset($input['task'])) { |
||
| 200 | foreach($input['task'] as $task) { |
||
| 201 | $jobPosterTask = new JobPosterKeyTask(); |
||
| 202 | $jobPosterTask->job_poster_id = $job->id; |
||
| 203 | $jobPosterTask->fill([ |
||
| 204 | 'en' => [ |
||
| 205 | 'description' => $task['en'] |
||
| 206 | ], |
||
| 207 | 'fr' => [ |
||
| 208 | 'description' => $task['fr'] |
||
| 209 | ] |
||
| 210 | ]); |
||
| 211 | $jobPosterTask->save(); |
||
| 212 | } |
||
| 213 | } |
||
| 214 | |||
| 215 | if (isset($input['question'])) { |
||
| 216 | foreach($input['question'] as $question) { |
||
| 217 | $jobQuestion = new JobPosterQuestion(); |
||
| 218 | $jobQuestion->job_poster_id = $job->id; |
||
| 219 | $jobQuestion->fill([ |
||
| 220 | 'en'=> [ |
||
| 221 | 'question' => $question['question']['en'], |
||
| 222 | 'description' => $question['description']['en'] |
||
| 223 | ], |
||
| 224 | 'fr'=> [ |
||
| 225 | 'question' => $question['question']['fr'], |
||
| 226 | 'description' => $question['description']['fr'] |
||
| 227 | ] |
||
| 228 | ]); |
||
| 229 | $jobQuestion->save(); |
||
| 230 | } |
||
| 231 | } |
||
| 232 | |||
| 233 | $criteria = $input['criteria']; |
||
| 234 | |||
| 235 | //Save new criteria |
||
| 236 | if (isset($criteria['new'])) { |
||
| 237 | foreach($criteria['new'] as $criteriaType => $criteriaTypeInput) { |
||
| 238 | foreach($criteriaTypeInput as $skillType => $skillTypeInput) { |
||
| 239 | foreach($skillTypeInput as $criteriaInput) { |
||
| 240 | $criteria = new Criteria(); |
||
| 241 | $criteria->job_poster_id = $job->id; |
||
| 242 | $criteria->fill([ |
||
| 243 | 'criteria_type_id' => CriteriaType::where('name', $criteriaType)->firstOrFail()->id, |
||
| 244 | 'skill_id' => $criteriaInput['skill_id'], |
||
| 245 | 'skill_level_id' => $criteriaInput['skill_level_id'], |
||
| 246 | 'en' => [ |
||
| 247 | 'description' => $criteriaInput['description']['en'], |
||
| 248 | ], |
||
| 249 | 'fr' => [ |
||
| 250 | 'description' => $criteriaInput['description']['fr'], |
||
| 251 | ], |
||
| 252 | ]); |
||
| 253 | $criteria->save(); |
||
| 254 | } |
||
| 255 | } |
||
| 256 | } |
||
| 257 | } |
||
| 258 | |||
| 259 | return redirect( route('manager.jobs.index') ); |
||
|
1 ignored issue
–
show
|
|||
| 260 | } |
||
| 262 |