Total Complexity | 10 |
Total Lines | 152 |
Duplicated Lines | 0 % |
Coverage | 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\View\View|\Illuminate\Contracts\View\Factory |
||
27 | */ |
||
28 | public function show(Request $request, Applicant $applicant) |
||
50 | ] |
||
51 | ); |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * Show the form for editing the logged-in applicant's profile |
||
56 | * |
||
57 | * @param Request $request |
||
1 ignored issue
–
show
|
|||
58 | * @return \Illuminate\Http\RedirectResponse |
||
59 | */ |
||
60 | public function editAuthenticated(Request $request): \Illuminate\Http\RedirectResponse |
||
61 | { |
||
62 | $applicant = $request->user()->applicant; |
||
63 | return redirect(route('profile.about.edit', $applicant)); |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * Show the form for editing an applicant profile |
||
68 | * |
||
69 | * @param Request $request Incoming request object. |
||
70 | * @param \App\Models\Applicant $applicant Applicant to view and edit. |
||
71 | * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory |
||
72 | */ |
||
73 | public function edit(Request $request, Applicant $applicant) |
||
74 | { |
||
75 | $profileQuestions = ApplicantProfileQuestion::all(); |
||
76 | |||
77 | $profileText = Lang::get('applicant/applicant_profile'); |
||
78 | |||
79 | $profileQuestionForms = []; |
||
80 | foreach ($profileQuestions as $question) { |
||
81 | $answerObj = $applicant->applicant_profile_answers |
||
82 | ->where('applicant_profile_question_id', $question->id)->first(); |
||
83 | $answer = $answerObj ? $answerObj->answer : null; |
||
84 | |||
85 | $formValues = [ |
||
86 | 'id' => $question->id, |
||
87 | 'question' => $question->question, |
||
88 | 'description' => $question->description, |
||
89 | 'answer' => $answer, |
||
90 | 'answer_label' => $profileText['about_section']['answer_label'], |
||
91 | 'input_name' => $this->answerFormInputName.'['.$question->id.']' |
||
92 | ]; |
||
93 | array_push($profileQuestionForms, $formValues); |
||
94 | } |
||
95 | |||
96 | return view( |
||
97 | 'applicant/profile_01_about', |
||
98 | [ |
||
99 | /* Localized strings*/ |
||
100 | 'profile' => $profileText, |
||
101 | /* Applicant Profile Questions */ |
||
102 | 'applicant_profile_questions' => $profileQuestionForms, |
||
103 | /* User Data */ |
||
104 | 'user' => $applicant->user, |
||
105 | 'applicant' => $applicant, |
||
106 | 'profile_photo_url' => '/images/user.png', //TODO: get real photos |
||
107 | |||
108 | 'form_submit_action' => route('profile.about.update', $applicant) |
||
109 | ] |
||
110 | ); |
||
111 | } |
||
112 | |||
113 | /** |
||
114 | * Update the specified resource in storage. |
||
115 | * |
||
116 | * @param Request $request Incoming request. |
||
117 | * @param \App\Models\Applicant $applicant Applicant object to update. |
||
118 | * @return \Illuminate\Http\RedirectResponse |
||
119 | */ |
||
120 | public function update(Request $request, Applicant $applicant): \Illuminate\Http\RedirectResponse |
||
168 | } |
||
169 | } |
||
170 |