Passed
Push — task/job-page-performance ( d16cf8...6360ae )
by Chris
06:50 queued 12s
created

JobController   B

Complexity

Total Complexity 47

Size/Duplication

Total Lines 572
Duplicated Lines 0 %

Test Coverage

Coverage 73.62%

Importance

Changes 0
Metric Value
wmc 47
eloc 267
dl 0
loc 572
ccs 187
cts 254
cp 0.7362
rs 8.64
c 0
b 0
f 0

13 Methods

Rating   Name   Duplication   Size   Complexity  
A index() 0 23 1
A fillAndSaveJobPosterTasks() 0 24 5
A populateDefaultQuestions() 0 35 3
B populateCreateView() 0 97 4
A fillAndSaveJobPosterQuestions() 0 26 5
A create() 0 3 1
A fillAndSaveJobPoster() 0 37 2
A managerIndex() 0 13 1
A submitForReview() 0 19 2
B show() 0 77 8
A store() 0 26 3
B fillAndSaveJobPosterCriteria() 0 40 10
A destroy() 0 3 1

How to fix   Complexity   

Complex Class

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
2
3
namespace App\Http\Controllers;
4
5
use Illuminate\Support\Facades\Lang;
6
use Illuminate\Support\Facades\Auth;
7
use Illuminate\Support\Facades\Log;
8
use Illuminate\Support\Facades\Mail;
9
use Illuminate\Http\RedirectResponse;
10
use Illuminate\Http\Request;
11
use Illuminate\Http\Response;
12
use Illuminate\View\View;
13
use App\Http\Controllers\Controller;
14
15
use Carbon\Carbon;
16
17
use App\Mail\JobPosterReviewRequested;
18
19
use App\Models\JobPoster;
20
use App\Models\JobPosterQuestion;
21
use App\Models\Lookup\JobTerm;
22
use App\Models\Lookup\Province;
23
use App\Models\Lookup\SecurityClearance;
24
use App\Models\Lookup\LanguageRequirement;
25
use App\Models\Lookup\CitizenshipDeclaration;
26
use App\Models\Lookup\Department;
27
use App\Models\Lookup\SkillLevel;
28
use App\Models\Lookup\CriteriaType;
29
use App\Models\Lookup\VeteranStatus;
30
use App\Models\JobApplication;
31
use App\Models\Criteria;
32
use App\Models\Skill;
33
use App\Models\JobPosterKeyTask;
34
35
use App\Services\Validation\JobPosterValidator;
36
use Jenssegers\Date\Date;
37
38
class JobController extends Controller
39
{
40
    /**
41
     * Display a listing of JobPosters.
42
     *
43
     * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory
44
     */
45
    public function index()
46
    {
47
        $now = Carbon::now();
48
49
        // Find published jobs that are currently open for applications.
50
        // Eager load required relationships: Department, Province, JobTerm.
51
        // Eager load the count of submitted applications, to prevent the relationship
52
        // from being actually loaded and firing off events.
53
        $jobs = JobPoster::where('open_date_time', '<=', $now)
54
            ->where('close_date_time', '>=', $now)
55
            ->where('published', true)
56
            ->with([
57
                'department',
58
                'province',
59
                'job_term',
60
            ])
61
            ->withCount([
62
                'submitted_applications',
63
            ])
64
            ->get();
65
        return view('applicant/job_index', [
66
            'job_index' => Lang::get('applicant/job_index'),
67
            'jobs' => $jobs
68
        ]);
69
    }
70
71
    /**
72
     * Display a listing of a manager's JobPosters.
73
     *
74
     * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory
75
     */
76 1
    public function managerIndex()
77
    {
78 1
        $manager = Auth::user()->manager;
0 ignored issues
show
Bug introduced by
Accessing manager on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
79 1
        $jobs = JobPoster::where('manager_id', $manager->id)
80 1
            ->withCount('submitted_applications')
81 1
            ->get();
82
83 1
        return view('manager/job_index', [
84
            /*Localization Strings*/
85 1
            'jobs_l10n' => Lang::get('manager/job_index'),
86
87
            /* Data */
88 1
            'jobs' => $jobs,
89
        ]);
90
    }
91
92
    /**
93
     * Submit the Job Poster for review.
94
     *
95
     * @param \Illuminate\Http\Request $request   Incoming request object.
96
     * @param \App\Models\JobPoster    $jobPoster Job Poster object.
97
     *
98
     * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory
99
     */
100 1
    public function submitForReview(Request $request, JobPoster $jobPoster)
101
    {
102
        // Update review request timestamp
103 1
        $jobPoster->review_requested_at = new Date();
104 1
        $jobPoster->save();
105 1
        $jobPoster->refresh();
106
107
        // Send email
108 1
        $reviewer_email = config('mail.reviewer_email');
109 1
        if (isset($reviewer_email)) {
110 1
            Mail::to($reviewer_email)->send(new JobPosterReviewRequested($jobPoster, Auth::user()));
0 ignored issues
show
Bug introduced by
It seems like Illuminate\Support\Facades\Auth::user() can also be of type null; however, parameter $manager of App\Mail\JobPosterReviewRequested::__construct() does only seem to accept App\Models\User, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

110
            Mail::to($reviewer_email)->send(new JobPosterReviewRequested($jobPoster, /** @scrutinizer ignore-type */ Auth::user()));
Loading history...
111
        } else {
112
            Log::error('The reviewer email environment variable is not set.');
113
        }
114
115 1
        return view('manager/job_index/job', [
116
            /*Localization Strings*/
117 1
            'jobs_l10n' => Lang::get('manager/job_index'),
118 1
            'job' => $jobPoster
119
        ]);
120
    }
121
122
    /**
123
     * Delete a draft Job Poster.
124
     *
125
     * @param \Illuminate\Http\Request $request   Incoming request object.
126
     * @param \App\Models\JobPoster    $jobPoster Job Poster object.
127
     *
128
     * @return void
129
     */
130
    public function destroy(Request $request, JobPoster $jobPoster) : void
131
    {
132
        $jobPoster->delete();
133
    }
134
135
    /**
136
     * Display the specified job poster.
137
     *
138
     * @param \Illuminate\Http\Request $request   Incoming request object.
139
     * @param \App\Models\JobPoster    $jobPoster Job Poster object.
140
     *
141
     * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory
142
     */
143 3
    public function show(Request $request, JobPoster $jobPoster)
144
    {
145 3
        $jobPoster->load([
146 3
            'department',
147
            'criteria.skill.skill_type',
148
            'manager.team_culture',
149
            'manager.work_environment'
150
        ]);
151
152 3
        $user = Auth::user();
0 ignored issues
show
Unused Code introduced by
The assignment to $user is dead and can be removed.
Loading history...
153
154
        //TODO: Improve workplace photos, and reference them in template direction from WorkEnvironment model
155 3
        $workplacePhotos = [];
156 3
        foreach ($jobPoster->manager->work_environment->workplace_photo_captions as $photoCaption) {
157
            $workplacePhotos[] = [
158
                'description' => $photoCaption->description,
159
                'url' => '/images/user.png'
160
            ];
161
        }
162
163
        //TODO: replace route('manager.show',manager.id) in templates with link using slug
164
165
        $criteria = [
166 3
            'essential' => $jobPoster->criteria->filter(
167
                function ($value, $key) {
168 2
                    return $value->criteria_type->name == 'essential';
169 3
                }
170
            ),
171 3
            'asset' => $jobPoster->criteria->filter(
172
                function ($value, $key) {
173 2
                    return $value->criteria_type->name == 'asset';
174 3
                }
175
            ),
176
        ];
177
178 3
        $jobLang = Lang::get('applicant/job_post');
179
180 3
        $applyButton = [];
181 3
        if (!$jobPoster->published && $this->authorize('update', $jobPoster)) {
182
            $applyButton = [
183 1
                'href' => route('manager.jobs.edit', $jobPoster->id),
184 1
                'title' => $jobLang['apply']['edit_link_title'],
185 1
                'text' => $jobLang['apply']['edit_link_label'],
186
            ];
187 2
        } elseif (Auth::check() && $jobPoster->isOpen()) {
188
            $applyButton = [
189 1
                'href' => route('job.application.edit.1', $jobPoster->id),
190 1
                'title' => $jobLang['apply']['apply_link_title'],
191 1
                'text' => $jobLang['apply']['apply_link_label'],
192
            ];
193 1
        } elseif (Auth::guest() && $jobPoster->isOpen()) {
194
            $applyButton = [
195 1
                'href' => route('job.application.edit.1', $jobPoster->id),
196 1
                'title' => $jobLang['apply']['login_link_title'],
197 1
                'text' => $jobLang['apply']['login_link_label'],
198
            ];
199
        } else {
200
            $applyButton = [
201
                'href' => null,
202
                'title' => null,
203
                'text' => $jobLang['apply']['job_closed_label'],
204
            ];
205
        }
206
207 3
        return view(
208 3
            'applicant/job_post',
209
            [
210 3
                'job_post' => $jobLang,
211 3
                'manager' => $jobPoster->manager,
212 3
                'manager_profile_photo_url' => '/images/user.png', //TODO get real photo
213 3
                'team_culture' => $jobPoster->manager->team_culture,
214 3
                'work_environment' => $jobPoster->manager->work_environment,
215 3
                'workplace_photos' => $workplacePhotos,
216 3
                'job' => $jobPoster,
217 3
                'criteria' => $criteria,
218 3
                'apply_button' => $applyButton,
219 3
                'skill_template' => Lang::get('common/skills'),
220
            ]
221
        );
222
    }
223
224
    /**
225
     * Display the form for creating a new Job Poster
226
     *
227
     * @param \Illuminate\Http\Request $request Incoming request object.
228
     *
229
     * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory Job Create view
230
     */
231 1
    public function create(Request $request)
232
    {
233 1
        return $this->populateCreateView($request);
234
    }
235
236
    /**
237
     * Display the form for editing an existing Job Poster
238
     *
239
     * @param \Illuminate\Http\Request $request   Incoming request object.
240
     * @param \App\Models\JobPoster    $jobPoster Job Poster object.
241
     *
242
     * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory Job Create view
243
     */
244 1
    public function edit(Request $request, JobPoster $jobPoster)
245
    {
246 1
        return $this->populateCreateView($request, $jobPoster);
247
    }
248
249
    /**
250
     * Get the manager from the request object and check if creating or editing
251
     *
252
     * @param \Illuminate\Http\Request $request   Incoming request object.
253
     * @param \App\Models\JobPoster    $jobPoster Optional Job Poster object.
254
     *
255
     * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory Job Create view
256
     */
257 2
    public function populateCreateView(Request $request, JobPoster $jobPoster = null)
258
    {
259 2
        $manager = $request->user() ? $request->user()->manager : null;
260 2
        if (isset($jobPoster)) {
261 1
            $job = $jobPoster;
262 1
            $route = ['manager.jobs.store', $jobPoster];
263 1
            $jobHeading = 'manager/job_edit';
264
        } else {
265 1
            $job = [];
266 1
            $defaultQuestions = $this->populateDefaultQuestions();
267 1
            if (!empty($defaultQuestions)) {
268 1
                $job['job_poster_questions'] = $defaultQuestions;
269
            }
270 1
            $route = ['manager.jobs.store'];
271 1
            $jobHeading = 'manager/job_create';
272
        }
273
274 2
        $skillLangs = Lang::get('common/skills');
275
276 2
        $softSkills = Skill::whereHas(
277 2
            'skill_type',
278
            function ($query) : void {
279 2
                $query->where('name', '=', 'soft');
280 2
            }
281 2
        )->get()
282 2
            ->mapWithKeys(
283
                function ($skill) {
284
                    return [
285 2
                        $skill->id => $skill->name
286
                    ];
287 2
                }
288
            )
289 2
            ->all();
290
291 2
        $hardSkills = Skill::whereHas(
292 2
            'skill_type',
293
            function ($query) : void {
294 2
                $query->where('name', '=', 'hard');
295 2
            }
296 2
        )->get()
297 2
            ->mapWithKeys(
298
                function ($skill) {
299
                    return [
300 2
                        $skill->id => $skill->name
301
                    ];
302 2
                }
303
            )
304 2
            ->all();
305
306 2
        asort($softSkills, SORT_LOCALE_STRING);
307 2
        asort($hardSkills, SORT_LOCALE_STRING);
308
309
        $skills = [
310
            'essential' => [
311 2
                'hard' => $hardSkills,
312 2
                'soft' => $softSkills
313
            ],
314
            'asset' => [
315 2
                'hard' => $hardSkills,
316 2
                'soft' => $softSkills
317
            ]
318
        ];
319
320 2
        $skillLevelCollection = SkillLevel::all();
321
322 2
        $skillLevels = array();
323
324 2
        $skillLevels['hard'] = $skillLevelCollection->mapWithKeys(
325
            function ($skillLevel) use ($skillLangs) {
326 2
                return [$skillLevel->id => $skillLangs['skill_levels']['hard'][$skillLevel->name]];
327 2
            }
328 2
        )->all();
329
330 2
        $skillLevels['soft'] = $skillLevelCollection->mapWithKeys(
331
            function ($skillLevel) use ($skillLangs) {
332 2
                return [$skillLevel->id => $skillLangs['skill_levels']['soft'][$skillLevel->name]];
333 2
            }
334 2
        )->all();
335
336 2
        return view(
337 2
            'manager/job_create',
338
            [
339
                /*Localization Strings*/
340 2
                'job_l10n' => Lang::get('manager/job_create'),
341
342
                /* Data */
343 2
                'job' => Lang::get($jobHeading),
344 2
                'manager' => $manager,
345 2
                'provinces' => Province::all(),
346 2
                'departments' => Department::all(),
347 2
                'language_requirments' => LanguageRequirement::all(),
348 2
                'security_clearances' => SecurityClearance::all(),
349 2
                'job' => $job,
350 2
                'form_action_url' => route(/** @scrutinizer ignore-type */ ...$route), // phpcs:ignore
0 ignored issues
show
Bug introduced by
$route is expanded, but the parameter $name of route() does not expect variable arguments. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

350
                'form_action_url' => route(/** @scrutinizer ignore-type */ /** @scrutinizer ignore-type */ ...$route), // phpcs:ignore
Loading history...
351 2
                'skills' => $skills,
352 2
                'skill_levels' => $skillLevels,
353 2
                'skill_template' => $skillLangs,
354
            ]
355
        );
356
    }
357
358
    /**
359
     * Create a new resource in storage
360
     *
361
     * @param \Illuminate\Http\Request $request   Incoming request object.
362
     * @param \App\Models\JobPoster    $jobPoster Optional Job Poster object.
363
     *
364
     * @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse A redirect to the Job Index
365
     */
366 1
    public function store(Request $request, JobPoster $jobPoster = null)
367
    {
368
        // Don't allow edits for published Job Posters
369
        // Also check auth while we're at it
370 1
        if (isset($jobPoster)) {
371
            $this->authorize('update', $jobPoster);
372
            JobPosterValidator::validateUnpublished($jobPoster);
373
        } else {
374 1
            $this->authorize('create', JobPoster::class);
375
        }
376
377 1
        $input = $request->input();
378
379 1
        $job = (isset($jobPoster) ? $jobPoster : new JobPoster());
380
381 1
        $job->manager_id = $request->user()->manager->id;
382
383 1
        $this->fillAndSaveJobPoster($input, $job);
384
385 1
        $this->fillAndSaveJobPosterTasks($input, $job, isset($jobPoster));
386
387 1
        $this->fillAndSaveJobPosterQuestions($input, $job, isset($jobPoster));
388
389 1
        $this->fillAndSaveJobPosterCriteria($input, $job, isset($jobPoster));
390
391 1
        return redirect(route('manager.jobs.show', $job->id));
392
    }
393
394
    /**
395
     * Fill Job Poster model's properties and save
396
     *
397
     * @param mixed[]               $input     Field values.
398
     * @param \App\Models\JobPoster $jobPoster Job Poster object.
399
     *
400
     * @return void
401
     */
402 1
    protected function fillAndSaveJobPoster(array $input, JobPoster $jobPoster) : void
403
    {
404 1
        $jobPoster->fill(
405
            [
406 1
                'job_term_id' => JobTerm::where('name', 'month')->firstOrFail()->id,
407 1
                'term_qty' => $input['term_qty'],
408 1
                'open_date_time' => new Date($input['open_date'] . $input['open_time']),
409 1
                'close_date_time' => new Date($input['close_date'] . $input['close_time']),
410 1
                'start_date_time' => new Date($input['start_date_time']),
411 1
                'department_id' => $input['department'],
412 1
                'province_id' => $input['province'],
413 1
                'salary_min' => $input['salary_min'],
414 1
                'salary_max' => $input['salary_max'],
415 1
                'noc' => $input['noc'],
416 1
                'classification' => $input['classification'],
417 1
                'security_clearance_id' => $input['security_clearance'],
418 1
                'language_requirement_id' => $input['language_requirement'],
419 1
                'remote_work_allowed' => (isset($input['remote_work_allowed']) ? $input['remote_work_allowed'] : false),
420
                'en' => [
421 1
                    'city' => $input['city'],
422 1
                    'title' => $input['title']['en'],
423 1
                    'impact' => $input['impact']['en'],
424 1
                    'branch' => $input['branch']['en'],
425 1
                    'division' => $input['division']['en'],
426 1
                    'education' => $input['education']['en'],
427
                ],
428
                'fr' => [
429 1
                    'city' => $input['city'],
430 1
                    'title' => $input['title']['fr'],
431 1
                    'impact' => $input['impact']['fr'],
432 1
                    'branch' => $input['branch']['fr'],
433 1
                    'division' => $input['division']['fr'],
434 1
                    'education' => $input['education']['fr'],
435
                ],
436
            ]
437
        );
438 1
        $jobPoster->save();
439 1
    }
440
441
    /**
442
     * Fill Job Poster's tasks and save
443
     *
444
     * @param mixed[]               $input     Field values.
445
     * @param \App\Models\JobPoster $jobPoster Job Poster object.
446
     * @param boolean               $replace   Remove existing relationships.
447
     *
448
     * @return void
449
     */
450 1
    protected function fillAndSaveJobPosterTasks(array $input, JobPoster $jobPoster, bool $replace) : void
451
    {
452 1
        if ($replace) {
453
            $jobPoster->job_poster_key_tasks()->delete();
454
        }
455
456 1
        if (!array_key_exists('task', $input) || !is_array($input['task'])) {
457 1
            return;
458
        }
459
460
        foreach ($input['task'] as $task) {
461
            $jobPosterTask = new JobPosterKeyTask();
462
            $jobPosterTask->job_poster_id = $jobPoster->id;
463
            $jobPosterTask->fill(
464
                [
465
                    'en' => [
466
                        'description' => $task['en']
467
                    ],
468
                    'fr' => [
469
                        'description' => $task['fr']
470
                    ]
471
                ]
472
            );
473
            $jobPosterTask->save();
474
        }
475
    }
476
477
    /**
478
     * Fill Job Poster's questions and save
479
     *
480
     * @param mixed[]               $input     Field values.
481
     * @param \App\Models\JobPoster $jobPoster Job Poster object.
482
     * @param boolean               $replace   Remove existing relationships.
483
     *
484
     * @return void
485
     */
486 1
    protected function fillAndSaveJobPosterQuestions(array $input, JobPoster $jobPoster, bool $replace) : void
487
    {
488 1
        if ($replace) {
489
            $jobPoster->job_poster_questions()->delete();
490
        }
491
492 1
        if (!array_key_exists('question', $input) || !is_array($input['question'])) {
493 1
            return;
494
        }
495
496
        foreach ($input['question'] as $question) {
497
            $jobQuestion = new JobPosterQuestion();
498
            $jobQuestion->job_poster_id = $jobPoster->id;
499
            $jobQuestion->fill(
500
                [
501
                    'en' => [
502
                        'question' => $question['question']['en'],
503
                        'description' => $question['description']['en']
504
                    ],
505
                    'fr' => [
506
                        'question' => $question['question']['fr'],
507
                        'description' => $question['description']['fr']
508
                    ]
509
                ]
510
            );
511
            $jobQuestion->save();
512
        }
513
    }
514
515
    /**
516
     * Fill Job Poster's criteria and save
517
     *
518
     * @param mixed[]               $input     Field values.
519
     * @param \App\Models\JobPoster $jobPoster Job Poster object.
520
     * @param boolean               $replace   Remove existing relationships.
521
     *
522
     * @return void
523
     */
524 1
    protected function fillAndSaveJobPosterCriteria(array $input, JobPoster $jobPoster, bool $replace) : void
525
    {
526 1
        if ($replace) {
527
            $jobPoster->criteria()->delete();
528
        }
529
530 1
        if (!array_key_exists('criteria', $input) || !is_array($input['criteria'])) {
531 1
            return;
532
        }
533
534
        $criteria = $input['criteria'];
535
536
        $combinedCriteria = [];
537
        if (isset($criteria['old'])) {
538
            $combinedCriteria = array_replace_recursive($combinedCriteria, $criteria['old']);
539
        }
540
        if (isset($criteria['new'])) {
541
            $combinedCriteria = array_replace_recursive($combinedCriteria, $criteria['new']);
542
        }
543
544
        if (! empty($combinedCriteria)) {
545
            foreach ($combinedCriteria as $criteriaType => $criteriaTypeInput) {
546
                foreach ($criteriaTypeInput as $skillType => $skillTypeInput) {
547
                    foreach ($skillTypeInput as $criteriaInput) {
548
                        $criteria = new Criteria();
549
                        $criteria->job_poster_id = $jobPoster->id;
550
                        $criteria->fill(
551
                            [
552
                                'criteria_type_id' => CriteriaType::where('name', $criteriaType)->firstOrFail()->id,
553
                                'skill_id' => $criteriaInput['skill_id'],
554
                                'skill_level_id' => $criteriaInput['skill_level_id'],
555
                                'en' => [
556
                                    'description' => $criteriaInput['description']['en'],
557
                                ],
558
                                'fr' => [
559
                                    'description' => $criteriaInput['description']['fr'],
560
                                ],
561
                            ]
562
                        );
563
                        $criteria->save();
564
                    }
565
                }
566
            }
567
        }
568
    }
569
570
    /**
571
     * Get the localized default questions and add them to an array.
572
     *
573
     * @return mixed[]|void
574
     */
575 1
    protected function populateDefaultQuestions()
576
    {
577
        $defaultQuestions = [
578 1
            'en' => array_values(Lang::get('manager/job_create', [], 'en')['questions']),
579 1
            'fr' => array_values(Lang::get('manager/job_create', [], 'fr')['questions']),
580
        ];
581
582 1
        if (count($defaultQuestions['en']) !== count($defaultQuestions['fr'])) {
583
            Log::warning('There must be the same number of French and English default questions for a Job Poster.');
584
            return;
585
        }
586
587 1
        $jobQuestions = [];
588
589 1
        for ($i = 0; $i < count($defaultQuestions['en']); $i++) {
0 ignored issues
show
Performance Best Practice introduced by
It seems like you are calling the size function count() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.

If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration:

for ($i=0; $i<count($array); $i++) { // calls count() on each iteration
}

// Better
for ($i=0, $c=count($array); $i<$c; $i++) { // calls count() just once
}
Loading history...
590 1
            $jobQuestion = new JobPosterQuestion();
591 1
            $jobQuestion->fill(
592
                [
593
                    'en' => [
594 1
                        'question' => $defaultQuestions['en'][$i],
595
                    ],
596
                    'fr' => [
597 1
                        'question' => $defaultQuestions['fr'][$i],
598
                    ]
599
                ]
600
            );
601
            // Workaround for Default Questions with empty descriptions
602
            // throwing an error during save.
603
            // The id isn't actually used during the fillAndSaveJobPosterQuestions
604
            // method call.
605 1
            $jobQuestion->id = $i + 1;
606 1
            $jobQuestions[] = $jobQuestion;
607
        }
608
609 1
        return $jobQuestions;
610
    }
611
}
612