Total Complexity | 48 |
Total Lines | 605 |
Duplicated Lines | 0 % |
Coverage | 73.93% |
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 | public function managerIndex() |
||
74 | { |
||
75 | $manager = Auth::user()->manager; |
||
|
|||
76 | 1 | $jobs = JobPoster::where('manager_id', $manager->id) |
|
77 | ->withCount('submitted_applications') |
||
78 | 1 | ->get(); |
|
79 | 1 | ||
80 | 1 | return view('manager/job_index', [ |
|
81 | 1 | /*Localization Strings*/ |
|
82 | 'jobs_l10n' => Lang::get('manager/job_index'), |
||
83 | 1 | ||
84 | /* Data */ |
||
85 | 1 | 'jobs' => $jobs, |
|
86 | ]); |
||
87 | } |
||
88 | 1 | ||
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 | public function submitForReview(Request $request, JobPoster $jobPoster) |
||
98 | { |
||
99 | // Update review request timestamp |
||
100 | 1 | $jobPoster->review_requested_at = new Date(); |
|
101 | $jobPoster->save(); |
||
102 | |||
103 | 1 | // 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 | if (isset($reviewer_email)) { |
||
109 | Mail::to($reviewer_email)->send(new JobPosterReviewRequested($jobPoster, Auth::user())); |
||
110 | 1 | } else { |
|
111 | 1 | Log::error('The reviewer email environment variable is not set.'); |
|
112 | 1 | } |
|
113 | |||
114 | return view('manager/job_index/job', [ |
||
115 | /*Localization Strings*/ |
||
116 | 'jobs_l10n' => Lang::get('manager/job_index'), |
||
117 | 1 | 'job' => $jobPoster |
|
118 | ]); |
||
119 | 1 | } |
|
120 | 1 | ||
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 | public function show(Request $request, JobPoster $jobPoster) |
||
143 | { |
||
144 | $jobPoster->load([ |
||
145 | 5 | 'department', |
|
146 | 'criteria.skill.skill_type', |
||
147 | 5 | 'manager.team_culture', |
|
148 | 5 | 'manager.work_environment' |
|
149 | ]); |
||
150 | |||
151 | $user = Auth::user(); |
||
152 | |||
153 | //TODO: Improve workplace photos, and reference them in template direction from WorkEnvironment model |
||
154 | 5 | $workplacePhotos = []; |
|
155 | foreach ($jobPoster->manager->work_environment->workplace_photo_captions as $photoCaption) { |
||
156 | $workplacePhotos[] = [ |
||
157 | 5 | 'description' => $photoCaption->description, |
|
158 | 5 | '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 | 'essential' => $jobPoster->criteria->filter( |
||
166 | function ($value, $key) { |
||
167 | return $value->criteria_type->name == 'essential'; |
||
168 | 5 | } |
|
169 | ), |
||
170 | 2 | 'asset' => $jobPoster->criteria->filter( |
|
171 | 5 | function ($value, $key) { |
|
172 | return $value->criteria_type->name == 'asset'; |
||
173 | 5 | } |
|
174 | ), |
||
175 | 2 | ]; |
|
176 | 5 | ||
177 | $jobLang = Lang::get('applicant/job_post'); |
||
178 | |||
179 | $applyButton = []; |
||
180 | 5 | if (!$jobPoster->published && $this->authorize('update', $jobPoster)) { |
|
181 | $applyButton = [ |
||
182 | 5 | 'href' => route('manager.jobs.edit', $jobPoster->id), |
|
183 | 5 | 'title' => $jobLang['apply']['edit_link_title'], |
|
184 | 'text' => $jobLang['apply']['edit_link_label'], |
||
185 | 3 | ]; |
|
186 | 3 | } elseif (Auth::check() && $jobPoster->isOpen()) { |
|
187 | 3 | $applyButton = [ |
|
188 | 'href' => route('job.application.edit.1', $jobPoster->id), |
||
189 | 2 | 'title' => $jobLang['apply']['apply_link_title'], |
|
190 | 'text' => $jobLang['apply']['apply_link_label'], |
||
191 | 1 | ]; |
|
192 | 1 | } elseif (Auth::guest() && $jobPoster->isOpen()) { |
|
193 | 1 | $applyButton = [ |
|
194 | 'href' => route('job.application.edit.1', $jobPoster->id), |
||
195 | 1 | 'title' => $jobLang['apply']['login_link_title'], |
|
196 | 'text' => $jobLang['apply']['login_link_label'], |
||
197 | 1 | ]; |
|
198 | 1 | } else { |
|
199 | 1 | $applyButton = [ |
|
200 | 'href' => null, |
||
201 | 'title' => null, |
||
202 | 'text' => $jobLang['apply']['job_closed_label'], |
||
203 | ]; |
||
204 | } |
||
205 | |||
206 | return view( |
||
207 | 'applicant/job_post', |
||
208 | [ |
||
209 | 5 | 'job_post' => $jobLang, |
|
210 | 5 | 'manager' => $jobPoster->manager, |
|
211 | '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 | 5 | ] |
|
220 | 5 | ); |
|
221 | 5 | } |
|
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 | 1 | $managerEn = $manager->translate('en'); |
|
234 | $managerFr = $manager->translate('fr'); |
||
235 | 1 | $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 | 1 | $jobPoster->save(); |
|
247 | return redirect()->route('manager.jobs.edit', $jobPoster->id); |
||
1 ignored issue
–
show
|
|||
248 | 1 | } |
|
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 | public function create(Request $request) |
||
258 | { |
||
259 | 2 | return $this->populateCreateView($request); |
|
260 | } |
||
261 | 2 | ||
262 | 2 | /** |
|
263 | 1 | * Display the form for editing an existing Job Poster |
|
264 | 1 | * |
|
265 | 1 | * @param \Illuminate\Http\Request $request Incoming request object. |
|
266 | * @param \App\Models\JobPoster $jobPoster Job Poster object. |
||
267 | 1 | * |
|
268 | 1 | * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory Job Create view |
|
269 | 1 | */ |
|
270 | 1 | public function edit(Request $request, JobPoster $jobPoster) |
|
271 | { |
||
272 | 1 | return $this->populateCreateView($request, $jobPoster); |
|
273 | 1 | } |
|
274 | |||
275 | /** |
||
276 | 2 | * Get the manager from the request object and check if creating or editing |
|
277 | * |
||
278 | 2 | * @param \Illuminate\Http\Request $request Incoming request object. |
|
279 | 2 | * @param \App\Models\JobPoster $jobPoster Optional Job Poster object. |
|
280 | * |
||
281 | 2 | * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory Job Create view |
|
282 | 2 | */ |
|
283 | 2 | public function populateCreateView(Request $request, JobPoster $jobPoster = null) |
|
284 | 2 | { |
|
285 | $manager = $request->user() ? $request->user()->manager : null; |
||
286 | if (isset($jobPoster)) { |
||
287 | 2 | $job = $jobPoster; |
|
288 | $route = ['manager.jobs.update', $jobPoster]; |
||
289 | 2 | $jobHeading = 'manager/job_edit'; |
|
290 | } else { |
||
291 | 2 | $job = []; |
|
292 | $defaultQuestions = $this->populateDefaultQuestions(); |
||
293 | 2 | if (!empty($defaultQuestions)) { |
|
294 | 2 | $job['job_poster_questions'] = $defaultQuestions; |
|
295 | } |
||
296 | 2 | $route = ['manager.jobs.store']; |
|
297 | 2 | $jobHeading = 'manager/job_create'; |
|
298 | 2 | } |
|
299 | 2 | ||
300 | $skillLangs = Lang::get('common/skills'); |
||
301 | |||
302 | 2 | $softSkills = Skill::whereHas( |
|
303 | 'skill_type', |
||
304 | 2 | function ($query) : void { |
|
305 | $query->where('name', '=', 'soft'); |
||
306 | 2 | } |
|
307 | )->get() |
||
308 | 2 | ->mapWithKeys( |
|
309 | 2 | function ($skill) { |
|
310 | return [ |
||
311 | $skill->id => $skill->name |
||
312 | ]; |
||
313 | 2 | } |
|
314 | 2 | ) |
|
315 | ->all(); |
||
316 | |||
317 | 2 | $hardSkills = Skill::whereHas( |
|
318 | 2 | 'skill_type', |
|
319 | function ($query) : void { |
||
320 | $query->where('name', '=', 'hard'); |
||
321 | } |
||
322 | 2 | )->get() |
|
323 | ->mapWithKeys( |
||
324 | 2 | function ($skill) { |
|
325 | return [ |
||
326 | 2 | $skill->id => $skill->name |
|
327 | ]; |
||
328 | 2 | } |
|
329 | 2 | ) |
|
330 | 2 | ->all(); |
|
331 | |||
332 | 2 | asort($softSkills, SORT_LOCALE_STRING); |
|
333 | asort($hardSkills, SORT_LOCALE_STRING); |
||
334 | 2 | ||
335 | 2 | $skills = [ |
|
336 | 2 | 'essential' => [ |
|
337 | 'hard' => $hardSkills, |
||
338 | 2 | 'soft' => $softSkills |
|
339 | 2 | ], |
|
340 | 'asset' => [ |
||
341 | 'hard' => $hardSkills, |
||
342 | 2 | 'soft' => $softSkills |
|
343 | ] |
||
344 | ]; |
||
345 | 2 | ||
346 | 2 | $skillLevelCollection = SkillLevel::all(); |
|
347 | 2 | ||
348 | 2 | $skillLevels = array(); |
|
349 | 2 | ||
350 | 2 | $skillLevels['hard'] = $skillLevelCollection->mapWithKeys( |
|
351 | 2 | function ($skillLevel) use ($skillLangs) { |
|
352 | 2 | return [$skillLevel->id => $skillLangs['skill_levels']['hard'][$skillLevel->name]]; |
|
353 | 2 | } |
|
354 | 2 | )->all(); |
|
355 | 2 | ||
356 | $skillLevels['soft'] = $skillLevelCollection->mapWithKeys( |
||
357 | function ($skillLevel) use ($skillLangs) { |
||
358 | return [$skillLevel->id => $skillLangs['skill_levels']['soft'][$skillLevel->name]]; |
||
359 | } |
||
360 | )->all(); |
||
361 | |||
362 | return view( |
||
363 | 'manager/job_create', |
||
364 | [ |
||
365 | /*Localization Strings*/ |
||
366 | 'job_l10n' => Lang::get('manager/job_create'), |
||
367 | |||
368 | 3 | /* Data */ |
|
369 | 'job' => Lang::get($jobHeading), |
||
370 | 'manager' => $manager, |
||
371 | 'provinces' => Province::all(), |
||
372 | 3 | 'departments' => Department::all(), |
|
373 | 'language_requirments' => LanguageRequirement::all(), |
||
374 | 'security_clearances' => SecurityClearance::all(), |
||
375 | 'job' => $job, |
||
376 | 3 | 'form_action_url' => route(/** @scrutinizer ignore-type */ ...$route), // phpcs:ignore |
|
377 | 'skills' => $skills, |
||
378 | 'skill_levels' => $skillLevels, |
||
379 | 3 | 'skill_template' => $skillLangs, |
|
380 | ] |
||
381 | 3 | ); |
|
382 | } |
||
383 | 3 | ||
384 | /** |
||
385 | 3 | * Create a new resource in storage |
|
386 | * |
||
387 | 3 | * @param \Illuminate\Http\Request $request Incoming request object. |
|
388 | * @param \App\Models\JobPoster $jobPoster Optional Job Poster object. |
||
389 | 3 | * |
|
390 | * @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse A redirect to the Job Index |
||
391 | 3 | */ |
|
392 | public function store(Request $request, JobPoster $jobPoster = null) |
||
393 | 3 | { |
|
394 | // Don't allow edits for published Job Posters |
||
395 | // Also check auth while we're at it |
||
396 | if (isset($jobPoster)) { |
||
397 | $this->authorize('update', $jobPoster); |
||
398 | JobPosterValidator::validateUnpublished($jobPoster); |
||
399 | } else { |
||
400 | $this->authorize('create', JobPoster::class); |
||
401 | } |
||
402 | |||
403 | $input = $request->input(); |
||
404 | 3 | ||
405 | $job = (isset($jobPoster) ? $jobPoster : new JobPoster()); |
||
406 | 3 | ||
407 | 3 | $job->manager_id = $request->user()->manager->id; |
|
408 | 3 | ||
409 | $this->fillAndSaveJobPoster($input, $job); |
||
410 | 3 | ||
411 | $this->fillAndSaveJobPosterTasks($input, $job, isset($jobPoster)); |
||
412 | 3 | ||
413 | 3 | $this->fillAndSaveJobPosterQuestions($input, $job, isset($jobPoster)); |
|
414 | 3 | ||
415 | 3 | $this->fillAndSaveJobPosterCriteria($input, $job, isset($jobPoster)); |
|
416 | 3 | ||
417 | 3 | return redirect(route('manager.jobs.show', $job->id)); |
|
418 | 3 | } |
|
419 | 3 | ||
420 | 3 | /** |
|
421 | 3 | * Fill Job Poster model's properties and save |
|
422 | 3 | * |
|
423 | 3 | * @param mixed[] $input Field values. |
|
424 | 3 | * @param \App\Models\JobPoster $jobPoster Job Poster object. |
|
425 | 3 | * |
|
426 | * @return void |
||
427 | 3 | */ |
|
428 | 3 | protected function fillAndSaveJobPoster(array $input, JobPoster $jobPoster) : void |
|
429 | 3 | { |
|
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 | $jobPoster->fill( |
||
435 | 3 | [ |
|
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 | 'department_id' => $input['department'], |
||
442 | 'province_id' => $input['province'], |
||
443 | 'salary_min' => $input['salary_min'], |
||
444 | 3 | 'salary_max' => $input['salary_max'], |
|
445 | 3 | 'noc' => $input['noc'], |
|
446 | 'classification' => $input['classification'], |
||
447 | 'security_clearance_id' => $input['security_clearance'], |
||
448 | 'language_requirement_id' => $input['language_requirement'], |
||
449 | 'remote_work_allowed' => (isset($input['remote_work_allowed']) ? $input['remote_work_allowed'] : false), |
||
450 | 'en' => [ |
||
451 | 'city' => $input['city'], |
||
452 | 'title' => $input['title']['en'], |
||
453 | 'impact' => $input['impact']['en'], |
||
454 | 'branch' => $input['branch']['en'], |
||
455 | 'division' => $input['division']['en'], |
||
456 | 3 | 'education' => $input['education']['en'], |
|
457 | ], |
||
458 | 3 | 'fr' => [ |
|
459 | 'city' => $input['city'], |
||
460 | 'title' => $input['title']['fr'], |
||
461 | 'impact' => $input['impact']['fr'], |
||
462 | 3 | 'branch' => $input['branch']['fr'], |
|
463 | 3 | 'division' => $input['division']['fr'], |
|
464 | 'education' => $input['education']['fr'], |
||
465 | ], |
||
466 | ] |
||
467 | ); |
||
468 | $jobPoster->save(); |
||
469 | } |
||
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 | 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 | protected function fillAndSaveJobPosterQuestions(array $input, JobPoster $jobPoster, bool $replace) : void |
||
517 | { |
||
518 | if ($replace) { |
||
519 | $jobPoster->job_poster_questions()->delete(); |
||
520 | } |
||
521 | |||
522 | if (!array_key_exists('question', $input) || !is_array($input['question'])) { |
||
523 | return; |
||
524 | } |
||
525 | |||
526 | foreach ($input['question'] as $question) { |
||
527 | $jobQuestion = new JobPosterQuestion(); |
||
528 | $jobQuestion->job_poster_id = $jobPoster->id; |
||
529 | $jobQuestion->fill( |
||
530 | 3 | [ |
|
531 | 'en' => [ |
||
532 | 3 | 'question' => $question['question']['en'], |
|
533 | 'description' => $question['description']['en'] |
||
534 | ], |
||
535 | 'fr' => [ |
||
536 | 3 | 'question' => $question['question']['fr'], |
|
537 | 3 | '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 | protected function fillAndSaveJobPosterCriteria(array $input, JobPoster $jobPoster, bool $replace) : void |
||
555 | { |
||
556 | if ($replace) { |
||
557 | $jobPoster->criteria()->delete(); |
||
558 | } |
||
559 | |||
560 | if (!array_key_exists('criteria', $input) || !is_array($input['criteria'])) { |
||
561 | 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 | 1 | [ |
|
582 | 'criteria_type_id' => CriteriaType::where('name', $criteriaType)->firstOrFail()->id, |
||
583 | 'skill_id' => $criteriaInput['skill_id'], |
||
584 | 1 | 'skill_level_id' => $criteriaInput['skill_level_id'], |
|
585 | 1 | 'en' => [ |
|
586 | 'description' => $criteriaInput['description']['en'], |
||
587 | ], |
||
588 | 1 | 'fr' => [ |
|
589 | 'description' => $criteriaInput['description']['fr'], |
||
590 | ], |
||
591 | ] |
||
592 | ); |
||
593 | 1 | $criteria->save(); |
|
594 | } |
||
595 | 1 | } |
|
596 | 1 | } |
|
597 | 1 | } |
|
598 | } |
||
599 | |||
600 | 1 | /** |
|
601 | * Get the localized default questions and add them to an array. |
||
602 | * |
||
603 | 1 | * @return mixed[]|void |
|
604 | */ |
||
605 | protected function populateDefaultQuestions() |
||
640 | } |
||
641 | } |
||
642 |