|
1
|
|
|
<?php |
|
2
|
|
|
|
|
|
|
|
|
|
3
|
|
|
namespace App\Http\Controllers; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Http\Request; |
|
6
|
|
|
use App\Models\JobPoster; |
|
7
|
|
|
use Illuminate\Support\Facades\Lang; |
|
8
|
|
|
use Illuminate\View\View; |
|
9
|
|
|
use App\Models\Skill; |
|
10
|
|
|
use App\Models\Lookup\SkillLevel; |
|
11
|
|
|
use App\Models\Lookup\AssessmentType; |
|
12
|
|
|
use App\Models\ScreeningPlan; |
|
13
|
|
|
use App\Models\Assessment; |
|
14
|
|
|
|
|
15
|
|
|
class ScreeningPlanController extends Controller |
|
|
|
|
|
|
16
|
|
|
{ |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
|
|
|
|
|
19
|
|
|
* Show the form for creating a new resource. |
|
20
|
|
|
* |
|
21
|
|
|
* @param JobPoster $job The job to create a screen plan for. |
|
|
|
|
|
|
22
|
|
|
* @return View |
|
|
|
|
|
|
23
|
|
|
*/ |
|
24
|
|
|
public function createForJob(JobPoster $jobPoster): View |
|
25
|
|
|
{ |
|
26
|
|
|
$jobPoster->load('criteria'); |
|
27
|
|
|
$skills = Skill::all(); |
|
|
|
|
|
|
28
|
|
|
debugbar()->debug($jobPoster->toArray()); |
|
29
|
|
|
return view( |
|
30
|
|
|
'manager/screening-plan', |
|
31
|
|
|
[ |
|
32
|
|
|
'screening' => Lang::get('manager/screening-plan'), |
|
33
|
|
|
'job' => $jobPoster, |
|
34
|
|
|
'skill_template' => Lang::get('common/skills'), |
|
35
|
|
|
'assessment_types' => AssessmentType::all(), |
|
36
|
|
|
] |
|
37
|
|
|
); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public function store(Request $request, JobPoster $jobPoster) |
|
|
|
|
|
|
41
|
|
|
{ |
|
42
|
|
|
//TODO: Validate every job criteria is represented |
|
43
|
|
|
//TODO: Validate every job criteria has at least one assessment (?) |
|
44
|
|
|
//TODO: Validate every assessment is correct and complete |
|
45
|
|
|
|
|
46
|
|
|
$plan = new ScreeningPlan(); |
|
47
|
|
|
$plan->job_poster_id = $jobPoster->id; |
|
48
|
|
|
$plan->version = ScreeningPlan::max('version') + 1; |
|
49
|
|
|
$plan->save(); |
|
50
|
|
|
|
|
51
|
|
|
if ($request->input('criteria')) { |
|
52
|
|
|
foreach ($request->input('criteria') as $criteriaId => $assessments) { |
|
53
|
|
|
foreach ($assessments['assessment'] as $assessmentData) { |
|
54
|
|
|
$assessment = new Assessment(); |
|
55
|
|
|
$assessment->screening_plan_id = $plan->id; |
|
56
|
|
|
$assessment->criterion_id = $criteriaId; |
|
57
|
|
|
$assessment->assessment_type_id = $assessmentData['assessment_type']; |
|
58
|
|
|
$assessment->save(); |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
return redirect(route('manager.jobs.screening_plan', $jobPoster)); |
|
|
|
|
|
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Delete the particular skill declaration in storage. |
|
68
|
|
|
* |
|
69
|
|
|
* @param \Illuminate\Http\Request $request The request object. |
|
|
|
|
|
|
70
|
|
|
* @param \App\Models\ScreeningPlan $screeningPlan The screening plan to delete. |
|
|
|
|
|
|
71
|
|
|
* @return \Illuminate\Http\Response |
|
|
|
|
|
|
72
|
|
|
*/ |
|
73
|
|
|
public function destroy(Request $request, ScreeningPlan $screeningPlan): \Illuminate\Http\Response |
|
74
|
|
|
{ |
|
75
|
|
|
$this->authorize('delete', $screeningPlan); |
|
76
|
|
|
$skillDeclaration->delete(); |
|
|
|
|
|
|
77
|
|
|
|
|
78
|
|
|
if ($request->ajax()) { |
|
79
|
|
|
$content = ['message' => 'Screening Plan deleted']; |
|
80
|
|
|
return $this->formatAjaxResponse($content); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
return redirect()->back(); |
|
|
|
|
|
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|