Completed
Push — feature/manager_portal_localiz... ( d6a71b...8301cb )
by Xander
12:38 queued 07:00
created

JobController::show()   B

Complexity

Conditions 5
Paths 6

Size

Total Lines 67
Code Lines 43

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 35
CRAP Score 5.0122

Importance

Changes 0
Metric Value
eloc 43
dl 0
loc 67
rs 8.9208
c 0
b 0
f 0
ccs 35
cts 38
cp 0.9211
cc 5
nc 6
nop 2
crap 5.0122

How to fix   Long Method   

Long Method

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:

1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
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\Http\RedirectResponse;
9
use Illuminate\Http\Request;
10
use Illuminate\Http\Response;
11
use Illuminate\View\View;
12
use App\Http\Controllers\Controller;
13
14
use Carbon\Carbon;
15
16
use App\Models\JobPoster;
17
use App\Models\JobPosterQuestion;
18
use App\Models\Lookup\JobTerm;
19
use App\Models\Lookup\Province;
20
use App\Models\Lookup\SecurityClearance;
21
use App\Models\Lookup\LanguageRequirement;
22
use App\Models\Lookup\CitizenshipDeclaration;
23
use App\Models\Lookup\Department;
24
use App\Models\Lookup\SkillLevel;
25
use App\Models\Lookup\CriteriaType;
26
use App\Models\Lookup\VeteranStatus;
27
use App\Models\JobApplication;
28
use App\Models\Criteria;
29
use App\Models\Skill;
30
use App\Models\JobPosterKeyTask;
31
32
use App\Services\Validation\JobPosterValidator;
33
use Jenssegers\Date\Date;
34
35
class JobController extends Controller
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class JobController
Loading history...
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
        $jobs = JobPoster::where('open_date_time', '<=', $now)
48
            ->where('close_date_time', '>=', $now)
49
            ->where('published', true)
50
            ->get();
51
        $jobs->load('manager.work_environment');
52
        return view('applicant/job_index', [
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
53
            'job_index' => Lang::get('applicant/job_index'),
54
            'jobs' => $jobs
55
        ]);
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
56
    }
57
58
    /**
59
     * Display a listing of a manager's JobPosters.
60
     *
61
     * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory
62
     */
63 2
    public function managerIndex()
64
    {
65 2
        $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...
66
67 2
        $veteran_applications = [];
68 2
        $citizen_applications = [];
69 2
        $other_applications = [];
70
71 2
        foreach ($manager->job_posters as $job) {
72 2
            $job->submitted_applications->load(['veteran_status', 'citizenship_declaration']);
73
            $veteran_applications[$job->id] = $job->submitted_applications->filter(function ($application) {
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
74
                return $application->veteran_status->name !== "none" &&
75
                    $application->citizenship_declaration->name === "citizen";
76 2
            });
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
77
            $citizen_applications[$job->id] = $job->submitted_applications->filter(function ($application) {
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
78
                return $application->veteran_status->name === "none" &&
79
                    $application->citizenship_declaration->name === "citizen";
80 2
            });
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
81
            $other_applications[$job->id] = $job->submitted_applications->filter(function ($application) {
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
82
                return $application->citizenship_declaration->name !== "citizen";
83 2
            });
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
84
        }
85
86 2
        return view('manager/job_index', [
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
87
            /*Localization Strings*/
88 2
            'jobs_l10n' => Lang::get('manager/job_index'),
89
90
            /* Data */
91 2
            'jobs' => $manager->job_posters,
92 2
            'veteran_applications' => $veteran_applications,
93 2
            'citizen_applications' => $citizen_applications,
94 2
            'other_applications' => $other_applications,
95
        ]);
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
96
    }
97
98
    /**
99
     * Display the specified job poster.
100
     *
101
     * @param \Illuminate\Http\Request $request   Incoming request object.
102
     * @param \App\Models\JobPoster    $jobPoster Job Poster object.
103
     *
104
     * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory
105
     */
106 6
    public function show(Request $request, JobPoster $jobPoster)
107
    {
108 6
        $user = Auth::user();
109
110
        //TODO: Improve workplace photos, and reference them in template direction from WorkEnvironment model
111 6
        $workplacePhotos = [];
112 6
        foreach ($jobPoster->manager->work_environment->workplace_photo_captions as $photoCaption) {
113
            $workplacePhotos[] = [
114
                'description' => $photoCaption->description,
115
                'url' => '/images/user.png'
116
            ];
117
        }
118
119
        //TODO: replace route('manager.show',manager.id) in templates with link using slug
120
121
        $criteria = [
122 6
            'essential' => $jobPoster->criteria->filter(
123
                function ($value, $key) {
124 4
                    return $value->criteria_type->name == 'essential';
125 6
                }
126
            ),
127 6
            'asset' => $jobPoster->criteria->filter(
128
                function ($value, $key) {
129 4
                    return $value->criteria_type->name == 'asset';
130 6
                }
131
            ),
132
        ];
133
134 6
        $jobLang = Lang::get('applicant/job_post');
135
136 6
        $applyButton = [];
137
138 6
        if (isset($user)) {
139 4
            if (!$jobPoster->published && $this->authorize('update', $jobPoster)) {
140
                $applyButton = [
141 2
                    'href' => route('manager.jobs.edit', $jobPoster->id),
142 2
                    'title' => $jobLang['apply']['edit_link_title'],
143 2
                    'text' => $jobLang['apply']['edit_link_label'],
144
                ];
145
            } else {
146
                $applyButton = [
147 2
                    'href' => route('job.application.edit.1', $jobPoster->id),
148 2
                    'title' => $jobLang['apply']['apply_link_title'],
149 4
                    'text' => $jobLang['apply']['apply_link_label'],
150
                ];
151
            }
152
        } else {
153
            $applyButton = [
154 2
                'href' => route('job.application.edit.1', $jobPoster->id),
155 2
                'title' => $jobLang['apply']['login_link_title'],
156 2
                'text' => $jobLang['apply']['login_link_label'],
157
            ];
158
        }
159
160 6
        return view(
161 6
            'applicant/job_post',
162
            [
163 6
                'job_post' => $jobLang,
164 6
                'manager' => $jobPoster->manager,
165 6
                'manager_profile_photo_url' => '/images/user.png', //TODO get real photo
166 6
                'team_culture' => $jobPoster->manager->team_culture,
167 6
                'work_environment' => $jobPoster->manager->work_environment,
168 6
                'workplace_photos' => $workplacePhotos,
169 6
                'job' => $jobPoster,
170 6
                'criteria' => $criteria,
171 6
                'apply_button' => $applyButton,
172 6
                'skill_template' => Lang::get('common/skills'),
173
            ]
174
        );
175
    }
176
177
    /**
178
     * Display the form for creating a new Job Poster
179
     *
180
     * @param \Illuminate\Http\Request $request Incoming request object.
181
     *
182
     * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory Job Create view
183
     */
184 2
    public function create(Request $request)
185
    {
186 2
        return $this->populateCreateView($request);
187
    }
188
189
    /**
190
     * Display the form for editing an existing Job Poster
191
     *
192
     * @param \Illuminate\Http\Request $request   Incoming request object.
193
     * @param \App\Models\JobPoster    $jobPoster Job Poster object.
194
     *
195
     * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory Job Create view
196
     */
197 2
    public function edit(Request $request, JobPoster $jobPoster)
198
    {
199 2
        return $this->populateCreateView($request, $jobPoster);
200
    }
201
202
    /**
203
     * Get the manager from the request object and check if creating or editing
204
     *
205
     * @param \Illuminate\Http\Request $request   Incoming request object.
206
     * @param \App\Models\JobPoster    $jobPoster Optional Job Poster object.
207
     *
208
     * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory Job Create view
209
     */
210 4
    public function populateCreateView(Request $request, JobPoster $jobPoster = null)
211
    {
212 4
        $manager = $request->user() ? $request->user()->manager : null;
213 4
        if (isset($jobPoster)) {
214 2
            $job = $jobPoster;
215 2
            $route = ['manager.jobs.store', $jobPoster];
216 2
            $jobHeading = 'manager/job_edit';
217
        } else {
218 2
            $job = [];
219 2
            $defaultQuestions = $this->populateDefaultQuestions();
220
            if (!empty($defaultQuestions)) {
221
                $job['job_poster_questions'] = $defaultQuestions;
222
            }
223
            $route = ['manager.jobs.store'];
224
            $jobHeading = 'manager/job_create';
225
        }
226
227 2
        $skillLangs = Lang::get('common/skills');
228
229 2
        $softSkills = Skill::whereHas(
230 2
            'skill_type',
231
            function ($query) : void {
232 2
                $query->where('name', '=', 'soft');
233 2
            }
234 2
        )->get()
235 2
            ->mapWithKeys(
236
                function ($skill) use ($skillLangs) {
237
                    return [
238 2
                        $skill->id => $skillLangs['skills'][$skill->name]['name']
239
                    ];
240 2
                }
241
            )
242 2
            ->all();
243
244 2
        $hardSkills = Skill::whereHas(
245 2
            'skill_type',
246
            function ($query) : void {
247 2
                $query->where('name', '=', 'hard');
248 2
            }
249 2
        )->get()
250 2
            ->mapWithKeys(
251
                function ($skill) use ($skillLangs) {
252
                    return [
253 2
                        $skill->id => $skillLangs['skills'][$skill->name]['name']
254
                    ];
255 2
                }
256
            )
257 2
            ->all();
258
259 2
        asort($softSkills, SORT_LOCALE_STRING);
260 2
        asort($hardSkills, SORT_LOCALE_STRING);
261
262
        $skills = [
263
            'essential' => [
264 2
                'hard' => $hardSkills,
265 2
                'soft' => $softSkills
266
            ],
267
            'asset' => [
268 2
                'hard' => $hardSkills,
269 2
                'soft' => $softSkills
270
            ]
271
        ];
272
273 2
        $skillLevelCollection = SkillLevel::all();
274
275 2
        $skillLevels = array();
276
277 2
        $skillLevels['hard'] = $skillLevelCollection->mapWithKeys(
278
            function ($skillLevel) use ($skillLangs) {
279 2
                return [$skillLevel->id => $skillLangs['skill_levels']['hard'][$skillLevel->name]];
280 2
            }
281 2
        )->all();
282
283 2
        $skillLevels['soft'] = $skillLevelCollection->mapWithKeys(
284
            function ($skillLevel) use ($skillLangs) {
285 2
                return [$skillLevel->id => $skillLangs['skill_levels']['soft'][$skillLevel->name]];
286 2
            }
287 2
        )->all();
288
289 2
        return view(
290 2
            'manager/job_create',
291
            [
292
                /*Localization Strings*/
293 2
                'job_l10n' => Lang::get('manager/job_create'),
294
295
                /* Data */
296 2
                'job' => Lang::get($jobHeading),
297 2
                'manager' => $manager,
298 2
                'provinces' => Province::all(),
299 2
                'departments' => Department::all(),
300 2
                'language_requirments' => LanguageRequirement::all(),
301 2
                'security_clearances' => SecurityClearance::all(),
302 2
                'job' => $job,
303 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

303
                'form_action_url' => route(/** @scrutinizer ignore-type */ /** @scrutinizer ignore-type */ ...$route), // phpcs:ignore
Loading history...
304 2
                'skills' => $skills,
305 2
                'skill_levels' => $skillLevels,
306 2
                'skill_template' => $skillLangs,
307
            ]
308
        );
309
    }
310
311
    /**
312
     * Create a new resource in storage
313
     *
314
     * @param \Illuminate\Http\Request $request   Incoming request object.
315
     * @param \App\Models\JobPoster    $jobPoster Optional Job Poster object.
316
     *
317
     * @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse A redirect to the Job Index
318
     */
319 2
    public function store(Request $request, JobPoster $jobPoster = null)
320
    {
321
        // Don't allow edits for published Job Posters
322
        // Also check auth while we're at it
323 2
        if (isset($jobPoster)) {
324
            $this->authorize('update', $jobPoster);
325
            JobPosterValidator::validateUnpublished($jobPoster);
326
        } else {
327 2
            $this->authorize('create', JobPoster::class);
328
        }
329
330 2
        $input = $request->input();
331
332 2
        $job = (isset($jobPoster) ? $jobPoster : new JobPoster());
333
334 2
        $job->manager_id = $request->user()->manager->id;
335 2
        $job->published = ($input['submit'] == 'publish');
336
337 2
        $this->fillAndSaveJobPoster($input, $job);
338
339 2
        $this->fillAndSaveJobPosterTasks($input, $job, isset($jobPoster));
340
341 2
        $this->fillAndSaveJobPosterQuestions($input, $job, isset($jobPoster));
342
343 2
        $this->fillAndSaveJobPosterCriteria($input, $job, isset($jobPoster));
344
345 2
        $route = $job->published ? route('manager.jobs.index') : route('manager.jobs.show', $job->id);
346
347 2
        return redirect($route);
348
    }
349
350
    /**
351
     * Fill Job Poster model's properties and save
352
     *
353
     * @param mixed[]               $input     Field values.
354
     * @param \App\Models\JobPoster $jobPoster Job Poster object.
355
     *
356
     * @return void
357
     */
358 2
    protected function fillAndSaveJobPoster(array $input, JobPoster $jobPoster) : void
359
    {
360 2
        $jobPoster->fill(
361
            [
362 2
                'job_term_id' => JobTerm::where('name', 'month')->firstOrFail()->id,
363 2
                'term_qty' => $input['term_qty'],
364 2
                'open_date_time' => new Date($input['open_date'] . $input['open_time']),
365 2
                'close_date_time' => new Date($input['close_date'] . $input['close_time']),
366 2
                'start_date_time' => new Date($input['start_date_time']),
367 2
                'department_id' => $input['department'],
368 2
                'province_id' => $input['province'],
369 2
                'salary_min' => $input['salary_min'],
370 2
                'salary_max' => $input['salary_max'],
371 2
                'noc' => $input['noc'],
372 2
                'classification' => $input['classification'],
373 2
                'security_clearance_id' => $input['security_clearance'],
374 2
                'language_requirement_id' => $input['language_requirement'],
375 2
                'remote_work_allowed' => (isset($input['remote_work_allowed']) ? $input['remote_work_allowed'] : false),
376
                'en' => [
377 2
                    'city' => $input['city'],
378 2
                    'title' => $input['title']['en'],
379 2
                    'impact' => $input['impact']['en'],
380 2
                    'branch' => $input['branch']['en'],
381 2
                    'division' => $input['division']['en'],
382 2
                    'education' => $input['education']['en'],
383
                ],
384
                'fr' => [
385 2
                    'city' => $input['city'],
386 2
                    'title' => $input['title']['fr'],
387 2
                    'impact' => $input['impact']['fr'],
388 2
                    'branch' => $input['branch']['fr'],
389 2
                    'division' => $input['division']['fr'],
390 2
                    'education' => $input['education']['fr'],
391
                ],
392
            ]
393
        );
394 2
        $jobPoster->save();
395 2
    }
396
397
    /**
398
     * Fill Job Poster's tasks and save
399
     *
400
     * @param mixed[]               $input     Field values.
401
     * @param \App\Models\JobPoster $jobPoster Job Poster object.
402
     * @param boolean               $replace   Remove existing relationships.
403
     *
404
     * @return void
405
     */
406 2
    protected function fillAndSaveJobPosterTasks(array $input, JobPoster $jobPoster, bool $replace) : void
407
    {
408 2
        if ($replace) {
409
            $jobPoster->job_poster_key_tasks()->delete();
410
        }
411
412 2
        if (!array_key_exists('task', $input) || !is_array($input['task'])) {
413 2
            return;
414
        }
415
416
        foreach ($input['task'] as $task) {
417
            $jobPosterTask = new JobPosterKeyTask();
418
            $jobPosterTask->job_poster_id = $jobPoster->id;
419
            $jobPosterTask->fill(
420
                [
421
                    'en' => [
422
                        'description' => $task['en']
423
                    ],
424
                    'fr' => [
425
                        'description' => $task['fr']
426
                    ]
427
                ]
428
            );
429
            $jobPosterTask->save();
430
        }
431
    }
432
433
    /**
434
     * Fill Job Poster's questions and save
435
     *
436
     * @param mixed[]               $input     Field values.
437
     * @param \App\Models\JobPoster $jobPoster Job Poster object.
438
     * @param boolean               $replace   Remove existing relationships.
439
     *
440
     * @return void
441
     */
442 2
    protected function fillAndSaveJobPosterQuestions(array $input, JobPoster $jobPoster, bool $replace) : void
443
    {
444 2
        if ($replace) {
445
            $jobPoster->job_poster_questions()->delete();
446
        }
447
448 2
        if (!array_key_exists('question', $input) || !is_array($input['question'])) {
449 2
            return;
450
        }
451
452
        foreach ($input['question'] as $question) {
453
            $jobQuestion = new JobPosterQuestion();
454
            $jobQuestion->job_poster_id = $jobPoster->id;
455
            $jobQuestion->fill(
456
                [
457
                    'en' => [
458
                        'question' => $question['question']['en'],
459
                        'description' => $question['description']['en']
460
                    ],
461
                    'fr' => [
462
                        'question' => $question['question']['fr'],
463
                        'description' => $question['description']['fr']
464
                    ]
465
                ]
466
            );
467
            $jobQuestion->save();
468
        }
469
    }
470
471
    /**
472
     * Fill Job Poster's criteria 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 2
    protected function fillAndSaveJobPosterCriteria(array $input, JobPoster $jobPoster, bool $replace) : void
481
    {
482 2
        if ($replace) {
483
            $jobPoster->criteria()->delete();
484
        }
485
486 2
        if (!array_key_exists('criteria', $input) || !is_array($input['criteria'])) {
487 2
            return;
488
        }
489
490
        $criteria = $input['criteria'];
491
492
        $combinedCriteria = [];
493
        if (isset($criteria['old'])) {
494
            $combinedCriteria = array_replace_recursive($combinedCriteria, $criteria['old']);
495
        }
496
        if (isset($criteria['new'])) {
497
            $combinedCriteria = array_replace_recursive($combinedCriteria, $criteria['new']);
498
        }
499
500
        if (! empty($combinedCriteria)) {
501
            foreach ($combinedCriteria as $criteriaType => $criteriaTypeInput) {
502
                foreach ($criteriaTypeInput as $skillType => $skillTypeInput) {
503
                    foreach ($skillTypeInput as $criteriaInput) {
504
                        $criteria = new Criteria();
505
                        $criteria->job_poster_id = $jobPoster->id;
506
                        $criteria->fill(
507
                            [
508
                                'criteria_type_id' => CriteriaType::where('name', $criteriaType)->firstOrFail()->id,
509
                                'skill_id' => $criteriaInput['skill_id'],
510
                                'skill_level_id' => $criteriaInput['skill_level_id'],
511
                                'en' => [
512
                                    'description' => $criteriaInput['description']['en'],
513
                                ],
514
                                'fr' => [
515
                                    'description' => $criteriaInput['description']['fr'],
516
                                ],
517
                            ]
518
                        );
519
                        $criteria->save();
520
                    }
521
                }
522
            }
523
        }
524
    }
525
526
    /**
527
     * Get the localized default questions and add them to an array.
528
     *
529
     * @return mixed[]|void
530
     */
531 2
    protected function populateDefaultQuestions()
532
    {
533
        $defaultQuestions = [
534 2
            'en' => array_values(Lang::get('manager/job_create', [], 'en')['questions']),
535
            'fr' => array_values(Lang::get('manager/job_create', [], 'fr')['questions']),
536
        ];
537
538
        if (count($defaultQuestions['en']) !== count($defaultQuestions['fr'])) {
539
            Log::warning('There must be the same number of French and English default questions for a Job Poster.');
540
            return;
541
        }
542
543
        $jobQuestions = [];
544
545
        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...
546
            $jobQuestion = new JobPosterQuestion();
547
            $jobQuestion->fill(
548
                [
549
                    'en' => [
550
                        'question' => $defaultQuestions['en'][$i],
551
                    ],
552
                    'fr' => [
553
                        'question' => $defaultQuestions['fr'][$i],
554
                    ]
555
                ]
556
            );
557
            // Workaround for Default Questions with empty descriptions
558
            // throwing an error during save.
559
            // The id isn't actually used during the fillAndSaveJobPosterQuestions
560
            // method call.
561
            $jobQuestion->id = $i + 1;
562
            $jobQuestions[] = $jobQuestion;
563
        }
564
565
        return $jobQuestions;
566
    }
567
}
568