1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Http\Controllers; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\Facades\Lang; |
6
|
|
|
use Illuminate\Http\Request; |
7
|
|
|
use App\Models\Lookup\ApplicantProfileQuestion; |
8
|
|
|
use App\Models\Applicant; |
9
|
|
|
use App\Http\Controllers\Controller; |
10
|
|
|
use App\Models\JobPoster; |
11
|
|
|
use App\Services\Validation\Rules\LinkedInUrlRule; |
12
|
|
|
use App\Services\Validation\Rules\TwitterHandleRule; |
13
|
|
|
use Facades\App\Services\WhichPortal; |
14
|
|
|
|
15
|
|
|
class ApplicantProfileController extends Controller |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @var string |
19
|
|
|
*/ |
20
|
|
|
protected $answerFormInputName = 'applicantProfileAnswer'; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Display the specified resource. |
24
|
|
|
* |
25
|
|
|
* @param \App\Models\Applicant $applicant Incoming Applicant object. |
26
|
|
|
* @return \Illuminate\Http\Response |
27
|
|
|
*/ |
28
|
|
|
public function profile(Applicant $applicant) |
29
|
|
|
{ |
30
|
|
|
$custom_breadcrumbs = [ |
31
|
|
|
'home' => route('home'), |
|
|
|
|
32
|
|
|
$applicant->user->full_name => '', |
33
|
|
|
]; |
34
|
|
|
|
35
|
|
|
return view( |
|
|
|
|
36
|
|
|
'manager/applicant_profile', |
37
|
|
|
[ |
38
|
|
|
// Localized strings. |
39
|
|
|
'profile' => Lang::get('manager/applicant_profile'), // Change text |
40
|
|
|
// Applicant data. |
41
|
|
|
'applicant' => $applicant, |
42
|
|
|
'profile_photo_url' => '/images/user.png', // TODO: get real photos. |
43
|
|
|
'custom_breadcrumbs' => $custom_breadcrumbs, |
44
|
|
|
] |
45
|
|
|
); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Display the specified resource. |
50
|
|
|
* |
51
|
|
|
* @param \App\Models\JobPoster $jobPoster Incoming JobPoster object. |
52
|
|
|
* @param \App\Models\Applicant $applicant Incoming Applicant object. |
53
|
|
|
* @return \Illuminate\Http\Response |
54
|
|
|
*/ |
55
|
|
|
public function showWithJob(JobPoster $jobPoster, Applicant $applicant) |
56
|
|
|
{ |
57
|
|
|
|
58
|
|
|
// Viewing this page is only possible if the applicant has applied to the specified job. |
59
|
|
|
if ($jobPoster->submitted_applications->firstWhere('applicant_id', '==', $applicant->id) === null) { |
60
|
|
|
return abort(404); |
|
|
|
|
61
|
|
|
} |
62
|
|
|
$custom_breadcrumbs = [ |
63
|
|
|
'home' => route('home'), |
|
|
|
|
64
|
|
|
'jobs' => route(WhichPortal::prefixRoute('jobs.index')), |
65
|
|
|
$jobPoster->title => route(WhichPortal::prefixRoute('jobs.summary'), $jobPoster), |
66
|
|
|
'applications' => route(WhichPortal::prefixRoute('jobs.applications'), $jobPoster), |
67
|
|
|
'profile' => '', |
68
|
|
|
]; |
69
|
|
|
|
70
|
|
|
return view( |
|
|
|
|
71
|
|
|
'manager/applicant_profile', |
72
|
|
|
[ |
73
|
|
|
// Localized strings. |
74
|
|
|
'profile' => Lang::get('manager/applicant_profile'), // Change text |
75
|
|
|
// Applicant data. |
76
|
|
|
'applicant' => $applicant, |
77
|
|
|
'profile_photo_url' => '/images/user.png', // TODO: get real photos. |
78
|
|
|
'custom_breadcrumbs' => $custom_breadcrumbs, |
79
|
|
|
] |
80
|
|
|
); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Show the form for editing the logged-in applicant's profile |
85
|
|
|
* |
86
|
|
|
* @param \Illuminate\Http\Request $request Incoming request. |
87
|
|
|
* @return \Illuminate\Http\Response |
88
|
|
|
*/ |
89
|
|
|
public function editAuthenticated(Request $request) |
90
|
|
|
{ |
91
|
|
|
$applicant = $request->user()->applicant; |
92
|
|
|
return redirect(route('profile.experience.edit', $applicant)); |
|
|
|
|
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Show the form for editing an applicant profile |
97
|
|
|
* |
98
|
|
|
* @param \Illuminate\Http\Request $request Incoming request object. |
99
|
|
|
* @param \App\Models\Applicant $applicant Applicant to view and edit. |
100
|
|
|
* @return \Illuminate\Http\Response |
101
|
|
|
*/ |
102
|
|
|
public function edit(Request $request, Applicant $applicant) |
103
|
|
|
{ |
104
|
|
|
$profileQuestions = ApplicantProfileQuestion::all(); |
105
|
|
|
|
106
|
|
|
$profileText = Lang::get('applicant/applicant_profile'); |
107
|
|
|
|
108
|
|
|
$profileQuestionForms = []; |
109
|
|
|
foreach ($profileQuestions as $question) { |
110
|
|
|
$answerObj = $applicant->applicant_profile_answers |
111
|
|
|
->where('applicant_profile_question_id', $question->id)->first(); |
112
|
|
|
$answer = $answerObj ? $answerObj->answer : null; |
113
|
|
|
|
114
|
|
|
$formValues = [ |
115
|
|
|
'id' => $question->id, |
116
|
|
|
'question' => $question->question, |
117
|
|
|
'description' => $question->description, |
118
|
|
|
'answer' => $answer, |
119
|
|
|
'answer_label' => $profileText['about_section']['answer_label'], |
120
|
|
|
'input_name' => $this->answerFormInputName . '[' . $question->id . ']' |
121
|
|
|
]; |
122
|
|
|
array_push($profileQuestionForms, $formValues); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
$linkedInUrlPattern = LinkedInUrlRule::PATTERN; |
126
|
|
|
$twitterHandlePattern = TwitterHandleRule::PATTERN; |
127
|
|
|
|
128
|
|
|
$custom_breadcrumbs = [ |
129
|
|
|
'home' => route('home'), |
|
|
|
|
130
|
|
|
'profile' => '', |
131
|
|
|
]; |
132
|
|
|
|
133
|
|
|
return view( |
|
|
|
|
134
|
|
|
'applicant/profile_01_about', |
135
|
|
|
[ |
136
|
|
|
// Localized strings. |
137
|
|
|
'profile' => $profileText, |
138
|
|
|
// Applicant data. |
139
|
|
|
'applicant' => $applicant, |
140
|
|
|
'profile_photo_url' => '/images/user.png', // TODO: get real photos. |
141
|
|
|
// Applicant Profile Questions. |
142
|
|
|
'applicant_profile_questions' => $profileQuestionForms, |
143
|
|
|
// Update route. |
144
|
|
|
'form_submit_action' => '', |
145
|
|
|
'linkedInUrlPattern' => $linkedInUrlPattern, |
146
|
|
|
'twitterHandlePattern' => $twitterHandlePattern, |
147
|
|
|
'custom_breadcrumbs' => $custom_breadcrumbs, |
148
|
|
|
] |
149
|
|
|
); |
150
|
|
|
} |
151
|
|
|
} |
152
|
|
|
|