| Total Complexity | 9 |
| Total Lines | 139 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | class ApplicantProfileController extends Controller |
||
| 17 | { |
||
| 18 | |||
| 19 | protected $answerFormInputName = 'applicantProfileAnswer'; |
||
|
1 ignored issue
–
show
|
|||
| 20 | |||
| 21 | /** |
||
| 22 | * Display the specified resource. |
||
| 23 | * |
||
| 24 | * @param Request $request |
||
|
1 ignored issue
–
show
|
|||
| 25 | * @param \App\Models\Applicant $applicant |
||
|
1 ignored issue
–
show
|
|||
| 26 | * @return \Illuminate\Http\Response |
||
| 27 | */ |
||
| 28 | public function show(Request $request, Applicant $applicant) |
||
| 50 | ] |
||
| 51 | ); |
||
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Show the form for editing the logged-in user's applicant profile |
||
| 56 | * |
||
| 57 | * @param Request $request Incoming request object. |
||
| 58 | * @param \App\Models\Applicant $applicant Applicant to view and edit. |
||
| 59 | * @return \Illuminate\Http\Response |
||
| 60 | */ |
||
| 61 | public function edit(Request $request, Applicant $applicant) |
||
| 62 | { |
||
| 63 | $profileQuestions = ApplicantProfileQuestion::all(); |
||
| 64 | |||
| 65 | $profileText = Lang::get('applicant/applicant_profile'); |
||
| 66 | |||
| 67 | $profileQuestionForms = []; |
||
| 68 | foreach ($profileQuestions as $question) { |
||
| 69 | $answerObj = $applicant->applicant_profile_answers |
||
| 70 | ->where('applicant_profile_question_id', $question->id)->first(); |
||
| 71 | $answer = $answerObj ? $answerObj->answer : null; |
||
| 72 | |||
| 73 | $formValues = [ |
||
| 74 | 'id' => $question->id, |
||
| 75 | 'question' => $question->question, |
||
| 76 | 'description' => $question->description, |
||
| 77 | 'answer' => $answer, |
||
| 78 | 'answer_label' => $profileText['about_section']['answer_label'], |
||
| 79 | 'input_name' => $this->answerFormInputName.'['.$question->id.']' |
||
| 80 | ]; |
||
| 81 | array_push($profileQuestionForms, $formValues); |
||
| 82 | } |
||
| 83 | |||
| 84 | return view( |
||
|
1 ignored issue
–
show
|
|||
| 85 | 'applicant/profile_01_about', [ |
||
| 86 | /* Localized strings*/ |
||
| 87 | 'profile' => $profileText, |
||
| 88 | /* Applicant Profile Questions */ |
||
| 89 | 'applicant_profile_questions' => $profileQuestionForms, |
||
| 90 | /* User Data */ |
||
| 91 | 'user' => $applicant->user, |
||
| 92 | 'applicant' => $applicant, |
||
| 93 | 'profile_photo_url' => '/images/user.png', //TODO: get real photos |
||
| 94 | |||
| 95 | 'form_submit_action' => route('profile.about.update', $applicant) |
||
| 96 | ] |
||
| 97 | ); |
||
| 98 | } |
||
| 99 | |||
| 100 | /** |
||
| 101 | * Update the specified resource in storage. |
||
| 102 | * |
||
| 103 | * @param Request $request Incoming request. |
||
| 104 | * @param \App\Models\Applicant $applicant Applicant object to update. |
||
| 105 | * @return \Illuminate\Http\RedirectResponse |
||
| 106 | */ |
||
| 107 | public function update(Request $request, Applicant $applicant) |
||
| 155 | } |
||
| 156 | } |
||
| 157 |