1
|
|
|
<?php |
2
|
|
|
|
|
|
|
|
3
|
|
|
namespace App\Http\Controllers; |
4
|
|
|
|
5
|
|
|
use Illuminate\Http\Request; |
6
|
|
|
use Illuminate\Support\Facades\Lang; |
7
|
|
|
use Illuminate\Support\Facades\Auth; |
8
|
|
|
use App\Models\JobApplication; |
9
|
|
|
use App\Models\Skill; |
10
|
|
|
|
11
|
|
|
class ApplicationController extends Controller |
|
|
|
|
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* Display a listing of the resource. |
15
|
|
|
* |
16
|
|
|
* @return \Illuminate\Http\Response |
17
|
|
|
*/ |
18
|
|
|
public function index() |
19
|
|
|
{ |
20
|
|
|
$applications = Auth::user()->applicant->job_applications; |
|
|
|
|
21
|
|
|
return view('applicant/application_index', [ |
|
|
|
|
22
|
|
|
"application_index" => Lang::get('applicant/application_index'), |
23
|
|
|
"applications" => $applications, |
24
|
|
|
"departments_template" => Lang::get('common/lookup/departments'), |
25
|
|
|
"manager_profile_photo" => '/images/user.png', //TODO: get real photo |
26
|
|
|
]); |
|
|
|
|
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Display specified application |
32
|
|
|
* |
33
|
|
|
* @param \App\Models\JobApplication $application |
|
|
|
|
34
|
|
|
* @return \Illuminate\Http\Response |
|
|
|
|
35
|
|
|
*/ |
36
|
|
|
public function show(JobApplication $application) |
37
|
|
|
{ |
38
|
|
|
$criteria = [ |
39
|
|
|
'essential' => $application->job_poster->criteria->filter(function($value, $key) { |
|
|
|
|
40
|
|
|
return $value->criteria_type->name == 'essential'; |
41
|
|
|
}), |
|
|
|
|
42
|
|
|
'asset' => $application->job_poster->criteria->filter(function($value, $key) { |
|
|
|
|
43
|
|
|
return $value->criteria_type->name == 'asset'; |
44
|
|
|
}), |
|
|
|
|
45
|
|
|
]; |
46
|
|
|
|
47
|
|
|
return view('common/application_preview', [ |
|
|
|
|
48
|
|
|
|
49
|
|
|
/* Application Template Data */ |
50
|
|
|
"application_template" => Lang::get("applicant/application_template"), |
51
|
|
|
"application_preview" => true, |
52
|
|
|
"preferred_language_template" => Lang::get('common/preferred_language'), |
53
|
|
|
"citizenship_declaration_template" => Lang::get('common/citizenship_declaration'), |
54
|
|
|
"veteran_status_template" => Lang::get('common/veteran_status'), |
55
|
|
|
|
56
|
|
|
/* Job Data */ |
57
|
|
|
"job" => $application->job_poster, |
58
|
|
|
|
59
|
|
|
/* Skills Data */ |
60
|
|
|
"skills" => Skill::all(), |
61
|
|
|
"skill_template" => Lang::get("common/skills"), |
62
|
|
|
'reference_template' => Lang::get('common/references'), |
63
|
|
|
'sample_template' => Lang::get('common/work_samples'), |
64
|
|
|
"criteria" => $criteria, |
65
|
|
|
|
66
|
|
|
/* Applicant Data */ |
67
|
|
|
"applicant" => $application->applicant, |
68
|
|
|
"job_application" => $application, |
69
|
|
|
]); |
|
|
|
|
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Delete the particular resource from storage. |
74
|
|
|
* |
75
|
|
|
* @param \Illuminate\Http\Request $request |
|
|
|
|
76
|
|
|
* @param \App\Models\JobApplication $application |
|
|
|
|
77
|
|
|
* @return \Illuminate\Http\Response |
|
|
|
|
78
|
|
|
*/ |
79
|
|
|
public function destroy(Request $request, JobApplication $application) |
80
|
|
|
{ |
81
|
|
|
$this->authorize('delete', $application); |
82
|
|
|
|
83
|
|
|
$application->delete(); |
84
|
|
|
|
85
|
|
|
if($request->ajax()) { |
|
|
|
|
86
|
|
|
return [ |
|
|
|
|
87
|
|
|
"message" => 'Application deleted' |
88
|
|
|
]; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
return redirect()->back(); |
|
|
|
|
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
} |
95
|
|
|
|