Code Duplication    Length = 18-18 lines in 4 locations

app/Http/Controllers/ApplicationByJobController.php 2 locations

@@ 491-508 (lines=18) @@
488
        }
489
490
        // Update old courses.
491
        if (isset($courses['old'])) {
492
            foreach ($courses['old'] as $id => $courseInput) {
493
                // Ensure this course belongs to this applicant.
494
                $course = $applicant->courses->firstWhere('id', $id);
495
                if ($course != null) {
496
                    $course->fill([
497
                        'name' => $courseInput['name'],
498
                        'institution' => $courseInput['institution'],
499
                        'course_status_id' => $courseInput['course_status_id'],
500
                        'start_date' => $courseInput['start_date'],
501
                        'end_date' => $courseInput['end_date']
502
                    ]);
503
                    $course->save();
504
                } else {
505
                    Log::warning("Applicant $applicant->id attempted to update course with invalid id: $id");
506
                }
507
            }
508
        }
509
510
        $work_experiences = $request->input('work_experiences');
511
@@ 537-554 (lines=18) @@
534
        }
535
536
        // Update old work_experiences.
537
        if (isset($work_experiences['old'])) {
538
            foreach ($work_experiences['old'] as $id => $workExperienceInput) {
539
                // Ensure this work_experience belongs to this applicant.
540
                $workExperience = $applicant->work_experiences->firstWhere('id', $id);
541
                if ($workExperience != null) {
542
                    $workExperience->fill([
543
                        'role' => $workExperienceInput['role'],
544
                        'company' => $workExperienceInput['company'],
545
                        'description' => $workExperienceInput['description'],
546
                        'start_date' => $workExperienceInput['start_date'],
547
                        'end_date' => $workExperienceInput['end_date']
548
                    ]);
549
                    $workExperience->save();
550
                } else {
551
                    Log::warning("Applicant $applicant->id attempted to update work_experience with invalid id: $id");
552
                }
553
            }
554
        }
555
556
        // Redirect to correct page.
557
        switch ($request->input('submit')) {

app/Http/Controllers/ExperienceController.php 2 locations

@@ 157-174 (lines=18) @@
154
        }
155
156
        // Update old courses.
157
        if (isset($courses['old'])) {
158
            foreach ($courses['old'] as $id => $courseInput) {
159
                // Ensure this course belongs to this applicant.
160
                $course = $applicant->courses->firstWhere('id', $id);
161
                if ($course != null) {
162
                    $course->fill([
163
                        'name' => $courseInput['name'],
164
                        'institution' => $courseInput['institution'],
165
                        'course_status_id' => $courseInput['course_status_id'],
166
                        'start_date' => $courseInput['start_date'],
167
                        'end_date' => $courseInput['end_date']
168
                    ]);
169
                    $course->save();
170
                } else {
171
                    Log::warning("Applicant $applicant->id attempted to update course with invalid id: $id");
172
                }
173
            }
174
        }
175
176
        $work_experiences = $input['work_experiences'];
177
@@ 214-231 (lines=18) @@
211
        }
212
213
        // Update old work_experiences.
214
        if (isset($work_experiences['old'])) {
215
            foreach ($work_experiences['old'] as $id => $workExperienceInput) {
216
                // Ensure this work_experience belongs to this applicant.
217
                $workExperience = $applicant->work_experiences->firstWhere('id', $id);
218
                if ($workExperience != null) {
219
                    $workExperience->fill([
220
                        'role' => $workExperienceInput['role'],
221
                        'company' => $workExperienceInput['company'],
222
                        'description' => $workExperienceInput['description'],
223
                        'start_date' => $workExperienceInput['start_date'],
224
                        'end_date' => $workExperienceInput['end_date']
225
                    ]);
226
                    $workExperience->save();
227
                } else {
228
                    Log::warning("Applicant $applicant->id attempted to update work_experience with invalid id: $id");
229
                }
230
            }
231
        }
232
233
        return redirect(route('profile.experience.edit', $applicant));
234
    }