Total Complexity | 48 |
Total Lines | 605 |
Duplicated Lines | 0 % |
Coverage | 70.37% |
Changes | 0 |
Complex classes like JobController often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use JobController, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
35 | class JobController extends Controller |
||
36 | { |
||
37 | /** |
||
38 | * Display a listing of JobPosters. |
||
39 | * |
||
40 | * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory |
||
41 | */ |
||
42 | public function index() |
||
43 | { |
||
44 | $now = Carbon::now(); |
||
45 | |||
46 | // Find published jobs that are currently open for applications. |
||
47 | // Eager load required relationships: Department, Province, JobTerm. |
||
48 | // Eager load the count of submitted applications, to prevent the relationship |
||
49 | // from being actually loaded and firing off events. |
||
50 | $jobs = JobPoster::where('open_date_time', '<=', $now) |
||
51 | ->where('close_date_time', '>=', $now) |
||
52 | ->where('published', true) |
||
53 | ->with([ |
||
54 | 'department', |
||
55 | 'province', |
||
56 | 'job_term', |
||
57 | ]) |
||
58 | ->withCount([ |
||
59 | 'submitted_applications', |
||
60 | ]) |
||
61 | ->get(); |
||
62 | return view('applicant/job_index', [ |
||
63 | 'job_index' => Lang::get('applicant/job_index'), |
||
64 | 'jobs' => $jobs |
||
65 | ]); |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * Display a listing of a manager's JobPosters. |
||
70 | * |
||
71 | * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory |
||
72 | */ |
||
73 | 1 | public function managerIndex() |
|
74 | { |
||
75 | 1 | $manager = Auth::user()->manager; |
|
|
|||
76 | 1 | $jobs = JobPoster::where('manager_id', $manager->id) |
|
77 | 1 | ->withCount('submitted_applications') |
|
78 | 1 | ->get(); |
|
79 | |||
80 | 1 | return view('manager/job_index', [ |
|
81 | /*Localization Strings*/ |
||
82 | 1 | 'jobs_l10n' => Lang::get('manager/job_index'), |
|
83 | |||
84 | /* Data */ |
||
85 | 1 | 'jobs' => $jobs, |
|
86 | ]); |
||
87 | } |
||
88 | |||
89 | /** |
||
90 | * Submit the Job Poster for review. |
||
91 | * |
||
92 | * @param \Illuminate\Http\Request $request Incoming request object. |
||
93 | * @param \App\Models\JobPoster $jobPoster Job Poster object. |
||
94 | * |
||
95 | * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory |
||
96 | */ |
||
97 | 1 | public function submitForReview(Request $request, JobPoster $jobPoster) |
|
98 | { |
||
99 | // Update review request timestamp |
||
100 | 1 | $jobPoster->review_requested_at = new Date(); |
|
101 | 1 | $jobPoster->save(); |
|
102 | |||
103 | // Refresh model instance with updated DB values. |
||
104 | 1 | $jobPoster = JobPoster::withCount('submitted_applications')->where('id', $jobPoster->id)->first(); |
|
105 | |||
106 | // Send email |
||
107 | 1 | $reviewer_email = config('mail.reviewer_email'); |
|
108 | 1 | if (isset($reviewer_email)) { |
|
109 | 1 | Mail::to($reviewer_email)->send(new JobPosterReviewRequested($jobPoster, Auth::user())); |
|
110 | } else { |
||
111 | Log::error('The reviewer email environment variable is not set.'); |
||
112 | } |
||
113 | |||
114 | 1 | return view('manager/job_index/job', [ |
|
115 | /*Localization Strings*/ |
||
116 | 1 | 'jobs_l10n' => Lang::get('manager/job_index'), |
|
117 | 1 | 'job' => $jobPoster |
|
118 | ]); |
||
119 | } |
||
120 | |||
121 | /** |
||
122 | * Delete a draft Job Poster. |
||
123 | * |
||
124 | * @param \Illuminate\Http\Request $request Incoming request object. |
||
125 | * @param \App\Models\JobPoster $jobPoster Job Poster object. |
||
126 | * |
||
127 | * @return void |
||
128 | */ |
||
129 | public function destroy(Request $request, JobPoster $jobPoster) : void |
||
130 | { |
||
131 | $jobPoster->delete(); |
||
132 | } |
||
133 | |||
134 | /** |
||
135 | * Display the specified job poster. |
||
136 | * |
||
137 | * @param \Illuminate\Http\Request $request Incoming request object. |
||
138 | * @param \App\Models\JobPoster $jobPoster Job Poster object. |
||
139 | * |
||
140 | * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory |
||
141 | */ |
||
142 | 5 | public function show(Request $request, JobPoster $jobPoster) |
|
143 | { |
||
144 | 5 | $jobPoster->load([ |
|
145 | 5 | 'department', |
|
146 | 'criteria.skill.skill_type', |
||
147 | 'manager.team_culture', |
||
148 | 'manager.work_environment' |
||
149 | ]); |
||
150 | |||
151 | 5 | $user = Auth::user(); |
|
152 | |||
153 | //TODO: Improve workplace photos, and reference them in template direction from WorkEnvironment model |
||
154 | 5 | $workplacePhotos = []; |
|
155 | 5 | foreach ($jobPoster->manager->work_environment->workplace_photo_captions as $photoCaption) { |
|
156 | $workplacePhotos[] = [ |
||
157 | 'description' => $photoCaption->description, |
||
158 | 'url' => '/images/user.png' |
||
159 | ]; |
||
160 | } |
||
161 | |||
162 | //TODO: replace route('manager.show',manager.id) in templates with link using slug |
||
163 | |||
164 | $criteria = [ |
||
165 | 5 | 'essential' => $jobPoster->criteria->filter( |
|
166 | function ($value, $key) { |
||
167 | 2 | return $value->criteria_type->name == 'essential'; |
|
168 | 5 | } |
|
169 | ), |
||
170 | 5 | 'asset' => $jobPoster->criteria->filter( |
|
171 | function ($value, $key) { |
||
172 | 2 | return $value->criteria_type->name == 'asset'; |
|
173 | 5 | } |
|
174 | ), |
||
175 | ]; |
||
176 | |||
177 | 5 | $jobLang = Lang::get('applicant/job_post'); |
|
178 | |||
179 | 5 | $applyButton = []; |
|
180 | 5 | if (!$jobPoster->published && $this->authorize('update', $jobPoster)) { |
|
181 | $applyButton = [ |
||
182 | 3 | 'href' => route('manager.jobs.edit', $jobPoster->id), |
|
183 | 3 | 'title' => $jobLang['apply']['edit_link_title'], |
|
184 | 3 | 'text' => $jobLang['apply']['edit_link_label'], |
|
185 | ]; |
||
186 | 2 | } elseif (Auth::check() && $jobPoster->isOpen()) { |
|
187 | $applyButton = [ |
||
188 | 1 | 'href' => route('job.application.edit.1', $jobPoster->id), |
|
189 | 1 | 'title' => $jobLang['apply']['apply_link_title'], |
|
190 | 1 | 'text' => $jobLang['apply']['apply_link_label'], |
|
191 | ]; |
||
192 | 1 | } elseif (Auth::guest() && $jobPoster->isOpen()) { |
|
193 | $applyButton = [ |
||
194 | 1 | 'href' => route('job.application.edit.1', $jobPoster->id), |
|
195 | 1 | 'title' => $jobLang['apply']['login_link_title'], |
|
196 | 1 | 'text' => $jobLang['apply']['login_link_label'], |
|
197 | ]; |
||
198 | } else { |
||
199 | $applyButton = [ |
||
200 | 'href' => null, |
||
201 | 'title' => null, |
||
202 | 'text' => $jobLang['apply']['job_closed_label'], |
||
203 | ]; |
||
204 | } |
||
205 | |||
206 | 5 | return view( |
|
207 | 5 | 'applicant/job_post', |
|
208 | [ |
||
209 | 5 | 'job_post' => $jobLang, |
|
210 | 5 | 'manager' => $jobPoster->manager, |
|
211 | 5 | 'manager_profile_photo_url' => '/images/user.png', //TODO get real photo |
|
212 | 5 | 'team_culture' => $jobPoster->manager->team_culture, |
|
213 | 5 | 'work_environment' => $jobPoster->manager->work_environment, |
|
214 | 5 | 'workplace_photos' => $workplacePhotos, |
|
215 | 5 | 'job' => $jobPoster, |
|
216 | 5 | 'criteria' => $criteria, |
|
217 | 5 | 'apply_button' => $applyButton, |
|
218 | 5 | 'skill_template' => Lang::get('common/skills'), |
|
219 | ] |
||
220 | ); |
||
221 | } |
||
222 | |||
223 | /** |
||
224 | * Create a blank job poster for the specified manager |
||
225 | * |
||
226 | * @param Manager $manager |
||
1 ignored issue
–
show
|
|||
227 | * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory Job Create view |
||
228 | */ |
||
229 | public function createAsManager(Manager $manager) |
||
230 | { |
||
231 | $jobPoster = new JobPoster(); |
||
232 | $jobPoster->manager_id = $manager->id; |
||
233 | $managerEn = $manager->translate('en'); |
||
234 | $managerFr = $manager->translate('fr'); |
||
235 | $jobPoster->fill([ |
||
236 | 'department_id' => $manager->department_id, |
||
237 | 'en' => [ |
||
238 | 'branch' => $managerEn->branch, |
||
239 | 'division' => $managerEn->division, |
||
240 | ], |
||
241 | 'fr' => [ |
||
242 | 'branch' => $managerFr->branch, |
||
243 | 'division' => $managerFr->division, |
||
244 | ] |
||
245 | ]); |
||
246 | $jobPoster->save(); |
||
247 | return redirect()->route('manager.jobs.edit', $jobPoster->id); |
||
1 ignored issue
–
show
|
|||
248 | } |
||
249 | |||
250 | /** |
||
251 | * Display the form for creating a new Job Poster |
||
252 | * |
||
253 | * @param \Illuminate\Http\Request $request Incoming request object. |
||
254 | * |
||
255 | * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory Job Create view |
||
256 | */ |
||
257 | 1 | public function create(Request $request) |
|
258 | { |
||
259 | 1 | return $this->populateCreateView($request); |
|
260 | } |
||
261 | |||
262 | /** |
||
263 | * Display the form for editing an existing Job Poster |
||
264 | * |
||
265 | * @param \Illuminate\Http\Request $request Incoming request object. |
||
266 | * @param \App\Models\JobPoster $jobPoster Job Poster object. |
||
267 | * |
||
268 | * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory Job Create view |
||
269 | */ |
||
270 | 1 | public function edit(Request $request, JobPoster $jobPoster) |
|
271 | { |
||
272 | 1 | return $this->populateCreateView($request, $jobPoster); |
|
273 | } |
||
274 | |||
275 | /** |
||
276 | * Get the manager from the request object and check if creating or editing |
||
277 | * |
||
278 | * @param \Illuminate\Http\Request $request Incoming request object. |
||
279 | * @param \App\Models\JobPoster $jobPoster Optional Job Poster object. |
||
280 | * |
||
281 | * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory Job Create view |
||
282 | */ |
||
283 | 2 | public function populateCreateView(Request $request, JobPoster $jobPoster = null) |
|
284 | { |
||
285 | 2 | $manager = $request->user() ? $request->user()->manager : null; |
|
286 | 2 | if (isset($jobPoster)) { |
|
287 | 1 | $job = $jobPoster; |
|
288 | 1 | $route = ['manager.jobs.update', $jobPoster]; |
|
289 | 1 | $jobHeading = 'manager/job_edit'; |
|
290 | } else { |
||
291 | 1 | $job = []; |
|
292 | 1 | $defaultQuestions = $this->populateDefaultQuestions(); |
|
293 | 1 | if (!empty($defaultQuestions)) { |
|
294 | 1 | $job['job_poster_questions'] = $defaultQuestions; |
|
295 | } |
||
296 | 1 | $route = ['manager.jobs.store']; |
|
297 | 1 | $jobHeading = 'manager/job_create'; |
|
298 | } |
||
299 | |||
300 | 2 | $skillLangs = Lang::get('common/skills'); |
|
301 | |||
302 | 2 | $softSkills = Skill::whereHas( |
|
303 | 2 | 'skill_type', |
|
304 | function ($query) : void { |
||
305 | 2 | $query->where('name', '=', 'soft'); |
|
306 | 2 | } |
|
307 | 2 | )->get() |
|
308 | 2 | ->mapWithKeys( |
|
309 | function ($skill) { |
||
310 | return [ |
||
311 | 2 | $skill->id => $skill->name |
|
312 | ]; |
||
313 | 2 | } |
|
314 | ) |
||
315 | 2 | ->all(); |
|
316 | |||
317 | 2 | $hardSkills = Skill::whereHas( |
|
318 | 2 | 'skill_type', |
|
319 | function ($query) : void { |
||
320 | 2 | $query->where('name', '=', 'hard'); |
|
321 | 2 | } |
|
322 | 2 | )->get() |
|
323 | 2 | ->mapWithKeys( |
|
324 | function ($skill) { |
||
325 | return [ |
||
326 | 2 | $skill->id => $skill->name |
|
327 | ]; |
||
328 | 2 | } |
|
329 | ) |
||
330 | 2 | ->all(); |
|
331 | |||
332 | 2 | asort($softSkills, SORT_LOCALE_STRING); |
|
333 | 2 | asort($hardSkills, SORT_LOCALE_STRING); |
|
334 | |||
335 | $skills = [ |
||
336 | 'essential' => [ |
||
337 | 2 | 'hard' => $hardSkills, |
|
338 | 2 | 'soft' => $softSkills |
|
339 | ], |
||
340 | 'asset' => [ |
||
341 | 2 | 'hard' => $hardSkills, |
|
342 | 2 | 'soft' => $softSkills |
|
343 | ] |
||
344 | ]; |
||
345 | |||
346 | 2 | $skillLevelCollection = SkillLevel::all(); |
|
347 | |||
348 | 2 | $skillLevels = array(); |
|
349 | |||
350 | 2 | $skillLevels['hard'] = $skillLevelCollection->mapWithKeys( |
|
351 | function ($skillLevel) use ($skillLangs) { |
||
352 | 2 | return [$skillLevel->id => $skillLangs['skill_levels']['hard'][$skillLevel->name]]; |
|
353 | 2 | } |
|
354 | 2 | )->all(); |
|
355 | |||
356 | 2 | $skillLevels['soft'] = $skillLevelCollection->mapWithKeys( |
|
357 | function ($skillLevel) use ($skillLangs) { |
||
358 | 2 | return [$skillLevel->id => $skillLangs['skill_levels']['soft'][$skillLevel->name]]; |
|
359 | 2 | } |
|
360 | 2 | )->all(); |
|
361 | |||
362 | 2 | return view( |
|
363 | 2 | 'manager/job_create', |
|
364 | [ |
||
365 | /*Localization Strings*/ |
||
366 | 2 | 'job_l10n' => Lang::get('manager/job_create'), |
|
367 | |||
368 | /* Data */ |
||
369 | 2 | 'job' => Lang::get($jobHeading), |
|
370 | 2 | 'manager' => $manager, |
|
371 | 2 | 'provinces' => Province::all(), |
|
372 | 2 | 'departments' => Department::all(), |
|
373 | 2 | 'language_requirments' => LanguageRequirement::all(), |
|
374 | 2 | 'security_clearances' => SecurityClearance::all(), |
|
375 | 2 | 'job' => $job, |
|
376 | 2 | 'form_action_url' => route(/** @scrutinizer ignore-type */ ...$route), // phpcs:ignore |
|
377 | 2 | 'skills' => $skills, |
|
378 | 2 | 'skill_levels' => $skillLevels, |
|
379 | 2 | 'skill_template' => $skillLangs, |
|
380 | ] |
||
381 | ); |
||
382 | } |
||
383 | |||
384 | /** |
||
385 | * Create a new resource in storage |
||
386 | * |
||
387 | * @param \Illuminate\Http\Request $request Incoming request object. |
||
388 | * @param \App\Models\JobPoster $jobPoster Optional Job Poster object. |
||
389 | * |
||
390 | * @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse A redirect to the Job Index |
||
391 | */ |
||
392 | 3 | public function store(Request $request, JobPoster $jobPoster = null) |
|
393 | { |
||
394 | // Don't allow edits for published Job Posters |
||
395 | // Also check auth while we're at it |
||
396 | 3 | if (isset($jobPoster)) { |
|
397 | $this->authorize('update', $jobPoster); |
||
398 | JobPosterValidator::validateUnpublished($jobPoster); |
||
399 | } else { |
||
400 | 3 | $this->authorize('create', JobPoster::class); |
|
401 | } |
||
402 | |||
403 | 3 | $input = $request->input(); |
|
404 | |||
405 | 3 | $job = (isset($jobPoster) ? $jobPoster : new JobPoster()); |
|
406 | |||
407 | 3 | $job->manager_id = $request->user()->manager->id; |
|
408 | |||
409 | 3 | $this->fillAndSaveJobPoster($input, $job); |
|
410 | |||
411 | 3 | $this->fillAndSaveJobPosterTasks($input, $job, isset($jobPoster)); |
|
412 | |||
413 | 3 | $this->fillAndSaveJobPosterQuestions($input, $job, isset($jobPoster)); |
|
414 | |||
415 | 3 | $this->fillAndSaveJobPosterCriteria($input, $job, isset($jobPoster)); |
|
416 | |||
417 | 3 | return redirect(route('manager.jobs.show', $job->id)); |
|
418 | } |
||
419 | |||
420 | /** |
||
421 | * Fill Job Poster model's properties and save |
||
422 | * |
||
423 | * @param mixed[] $input Field values. |
||
424 | * @param \App\Models\JobPoster $jobPoster Job Poster object. |
||
425 | * |
||
426 | * @return void |
||
427 | */ |
||
428 | 3 | protected function fillAndSaveJobPoster(array $input, JobPoster $jobPoster) : void |
|
429 | { |
||
430 | 3 | $closeDate = new Date($input['close_date']); |
|
431 | 3 | $openDate = new Date($input['open_date']); |
|
432 | 3 | $startDate = new Date($input['start_date']); |
|
433 | |||
434 | 3 | $jobPoster->fill( |
|
435 | [ |
||
436 | 3 | 'job_term_id' => JobTerm::where('name', 'month')->firstOrFail()->id, |
|
437 | 3 | 'term_qty' => $input['term_qty'], |
|
438 | 3 | 'open_date_time' => pstDayStartToUtcTime($openDate->year, $openDate->month, $openDate->day), |
|
439 | 3 | 'close_date_time' => pstDayEndToUtcTime($closeDate->year, $closeDate->month, $closeDate->day), |
|
440 | 3 | 'start_date_time' => pstDayStartToUtcTime($startDate->year, $startDate->month, $startDate->day), |
|
441 | 3 | 'department_id' => $input['department'], |
|
442 | 3 | 'province_id' => $input['province'], |
|
443 | 3 | 'salary_min' => $input['salary_min'], |
|
444 | 3 | 'salary_max' => $input['salary_max'], |
|
445 | 3 | 'noc' => $input['noc'], |
|
446 | 3 | 'classification' => $input['classification'], |
|
447 | 3 | 'security_clearance_id' => $input['security_clearance'], |
|
448 | 3 | 'language_requirement_id' => $input['language_requirement'], |
|
449 | 3 | 'remote_work_allowed' => (isset($input['remote_work_allowed']) ? $input['remote_work_allowed'] : false), |
|
450 | 'en' => [ |
||
451 | 3 | 'city' => $input['city'], |
|
452 | 3 | 'title' => $input['title']['en'], |
|
453 | 3 | 'impact' => $input['impact']['en'], |
|
454 | 3 | 'branch' => $input['branch']['en'], |
|
455 | 3 | 'division' => $input['division']['en'], |
|
456 | 3 | 'education' => $input['education']['en'], |
|
457 | ], |
||
458 | 'fr' => [ |
||
459 | 3 | 'city' => $input['city'], |
|
460 | 3 | 'title' => $input['title']['fr'], |
|
461 | 3 | 'impact' => $input['impact']['fr'], |
|
462 | 3 | 'branch' => $input['branch']['fr'], |
|
463 | 3 | 'division' => $input['division']['fr'], |
|
464 | 3 | 'education' => $input['education']['fr'], |
|
465 | ], |
||
466 | ] |
||
467 | ); |
||
468 | 3 | $jobPoster->save(); |
|
469 | 3 | } |
|
470 | |||
471 | /** |
||
472 | * Fill Job Poster's tasks and save |
||
473 | * |
||
474 | * @param mixed[] $input Field values. |
||
475 | * @param \App\Models\JobPoster $jobPoster Job Poster object. |
||
476 | * @param boolean $replace Remove existing relationships. |
||
477 | * |
||
478 | * @return void |
||
479 | */ |
||
480 | 3 | protected function fillAndSaveJobPosterTasks(array $input, JobPoster $jobPoster, bool $replace) : void |
|
504 | } |
||
505 | } |
||
506 | |||
507 | /** |
||
508 | * Fill Job Poster's questions and save |
||
509 | * |
||
510 | * @param mixed[] $input Field values. |
||
511 | * @param \App\Models\JobPoster $jobPoster Job Poster object. |
||
512 | * @param boolean $replace Remove existing relationships. |
||
513 | * |
||
514 | * @return void |
||
515 | */ |
||
516 | 3 | protected function fillAndSaveJobPosterQuestions(array $input, JobPoster $jobPoster, bool $replace) : void |
|
517 | { |
||
518 | 3 | if ($replace) { |
|
519 | $jobPoster->job_poster_questions()->delete(); |
||
520 | } |
||
521 | |||
522 | 3 | if (!array_key_exists('question', $input) || !is_array($input['question'])) { |
|
523 | 3 | return; |
|
524 | } |
||
525 | |||
526 | foreach ($input['question'] as $question) { |
||
527 | $jobQuestion = new JobPosterQuestion(); |
||
528 | $jobQuestion->job_poster_id = $jobPoster->id; |
||
529 | $jobQuestion->fill( |
||
530 | [ |
||
531 | 'en' => [ |
||
532 | 'question' => $question['question']['en'], |
||
533 | 'description' => $question['description']['en'] |
||
534 | ], |
||
535 | 'fr' => [ |
||
536 | 'question' => $question['question']['fr'], |
||
537 | 'description' => $question['description']['fr'] |
||
538 | ] |
||
539 | ] |
||
540 | ); |
||
541 | $jobQuestion->save(); |
||
542 | } |
||
543 | } |
||
544 | |||
545 | /** |
||
546 | * Fill Job Poster's criteria and save |
||
547 | * |
||
548 | * @param mixed[] $input Field values. |
||
549 | * @param \App\Models\JobPoster $jobPoster Job Poster object. |
||
550 | * @param boolean $replace Remove existing relationships. |
||
551 | * |
||
552 | * @return void |
||
553 | */ |
||
554 | 3 | protected function fillAndSaveJobPosterCriteria(array $input, JobPoster $jobPoster, bool $replace) : void |
|
555 | { |
||
556 | 3 | if ($replace) { |
|
557 | $jobPoster->criteria()->delete(); |
||
558 | } |
||
559 | |||
560 | 3 | if (!array_key_exists('criteria', $input) || !is_array($input['criteria'])) { |
|
561 | 3 | return; |
|
562 | } |
||
563 | |||
564 | $criteria = $input['criteria']; |
||
565 | |||
566 | $combinedCriteria = []; |
||
567 | if (isset($criteria['old'])) { |
||
568 | $combinedCriteria = array_replace_recursive($combinedCriteria, $criteria['old']); |
||
569 | } |
||
570 | if (isset($criteria['new'])) { |
||
571 | $combinedCriteria = array_replace_recursive($combinedCriteria, $criteria['new']); |
||
572 | } |
||
573 | |||
574 | if (! empty($combinedCriteria)) { |
||
575 | foreach ($combinedCriteria as $criteriaType => $criteriaTypeInput) { |
||
576 | foreach ($criteriaTypeInput as $skillType => $skillTypeInput) { |
||
577 | foreach ($skillTypeInput as $criteriaInput) { |
||
578 | $criteria = new Criteria(); |
||
579 | $criteria->job_poster_id = $jobPoster->id; |
||
580 | $criteria->fill( |
||
581 | [ |
||
582 | 'criteria_type_id' => CriteriaType::where('name', $criteriaType)->firstOrFail()->id, |
||
583 | 'skill_id' => $criteriaInput['skill_id'], |
||
584 | 'skill_level_id' => $criteriaInput['skill_level_id'], |
||
585 | 'en' => [ |
||
586 | 'description' => $criteriaInput['description']['en'], |
||
587 | ], |
||
588 | 'fr' => [ |
||
589 | 'description' => $criteriaInput['description']['fr'], |
||
590 | ], |
||
591 | ] |
||
592 | ); |
||
593 | $criteria->save(); |
||
594 | } |
||
595 | } |
||
596 | } |
||
597 | } |
||
598 | } |
||
599 | |||
600 | /** |
||
601 | * Get the localized default questions and add them to an array. |
||
602 | * |
||
603 | * @return mixed[]|void |
||
604 | */ |
||
605 | 1 | protected function populateDefaultQuestions() |
|
640 | } |
||
641 | } |
||
642 |