1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Created by Reliese Model. |
5
|
|
|
* Date: Thu, 12 Jul 2018 22:39:27 +0000. |
6
|
|
|
*/ |
|
|
|
|
7
|
|
|
|
8
|
|
|
namespace App\Models; |
9
|
|
|
use App\Models\Lookup\VeteranStatus; |
10
|
|
|
use App\Models\Lookup\PreferredLanguage; |
11
|
|
|
use App\Models\Lookup\CitizenshipDeclaration; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Class JobApplication |
15
|
|
|
* |
16
|
|
|
* @property int $id |
17
|
|
|
* @property int $job_poster_id |
18
|
|
|
* @property int $application_status_id |
19
|
|
|
* @property int $citizenship_declaration_id |
20
|
|
|
* @property int $veteran_status_id |
21
|
|
|
* @property int $preferred_language_id |
22
|
|
|
* @property int $applicant_id |
23
|
|
|
* @property int $applicant_snapshot_id |
24
|
|
|
* @property \Jenssegers\Date\Date $created_at |
25
|
|
|
* @property \Jenssegers\Date\Date $updated_at |
26
|
|
|
* |
27
|
|
|
* @property \App\Models\Applicant $applicant |
28
|
|
|
* @property \App\Models\Applicant $applicant_snapshot |
29
|
|
|
* @property \App\Models\Lookup\ApplicationStatus $application_status |
30
|
|
|
* @property \App\Models\Lookup\CitizenshipDeclaration $citizenship_declaration |
31
|
|
|
* @property \App\Models\Lookup\VeteranStatus $veteran_status |
32
|
|
|
* @property \App\Models\Lookup\PreferredLanguage $preferred_language |
33
|
|
|
* @property \App\Models\JobPoster $job_poster |
34
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $job_application_answers |
35
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $skill_declarations |
36
|
|
|
*/ |
|
|
|
|
37
|
|
|
class JobApplication extends BaseModel { |
|
|
|
|
38
|
|
|
|
39
|
|
|
protected $casts = [ |
40
|
|
|
'job_poster_id' => 'int', |
41
|
|
|
'application_status_id' => 'int', |
42
|
|
|
'citizenship_declaration_id' => 'int', |
43
|
|
|
'veteran_status_id' => 'int', |
44
|
|
|
'preferred_language_id' => 'int', |
45
|
|
|
'applicant_id' => 'int', |
46
|
|
|
'applicant_snapshot_id' => 'int' |
47
|
|
|
]; |
48
|
|
|
protected $fillable = [ |
49
|
|
|
'citizenship_declaration_id', |
50
|
|
|
'veteran_status_id', |
51
|
|
|
'preferred_language_id', |
52
|
|
|
]; |
53
|
|
|
|
54
|
|
|
protected function createApplicantSnapshot($applicant_id) { |
|
|
|
|
55
|
|
|
$applicant = Applicant::where('id', $applicant_id)->firstOrFail(); |
56
|
|
|
|
57
|
|
|
$snapshot = $applicant->replicate(); |
|
|
|
|
58
|
|
|
|
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function applicant() { |
|
|
|
|
62
|
|
|
return $this->belongsTo(\App\Models\Applicant::class); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function applicant_snapshot() { |
|
|
|
|
66
|
|
|
return $this->belongsTo(\App\Models\Applicant::class, 'applicant_snapshot_id'); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function application_status() { |
|
|
|
|
70
|
|
|
return $this->belongsTo(\App\Models\Lookup\ApplicationStatus::class); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function citizenship_declaration() { |
|
|
|
|
74
|
|
|
return $this->belongsTo(\App\Models\Lookup\CitizenshipDeclaration::class); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function veteran_status() { |
|
|
|
|
78
|
|
|
return $this->belongsTo(\App\Models\Lookup\VeteranStatus::class); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
public function preferred_language() { |
|
|
|
|
82
|
|
|
return $this->belongsTo(\App\Models\Lookup\PreferredLanguage::class); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function job_poster() { |
|
|
|
|
86
|
|
|
return $this->belongsTo(\App\Models\JobPoster::class); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
public function job_application_answers() { |
|
|
|
|
90
|
|
|
return $this->hasMany(\App\Models\JobApplicationAnswer::class); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Return either 'complete', 'incomplete' or 'error', depending on the |
95
|
|
|
* status of the requested section. |
96
|
|
|
* |
97
|
|
|
* @param string $section Should be one of: |
|
|
|
|
98
|
|
|
* 'basics' |
|
|
|
|
99
|
|
|
* 'experience' |
|
|
|
|
100
|
|
|
* 'essential_skills' |
|
|
|
|
101
|
|
|
* 'asset_skills' |
|
|
|
|
102
|
|
|
* 'preview' |
|
|
|
|
103
|
|
|
* |
104
|
|
|
* @return string $status 'complete', 'incomplete' or 'error' |
105
|
|
|
*/ |
106
|
|
|
public function getSectionStatus(string $section) { |
107
|
|
|
//TODO: determine whether sections are complete or opcache_invalid |
108
|
|
|
|
109
|
|
|
$status = 'incomplete'; |
110
|
|
|
switch($section) { |
111
|
|
|
case 'basics': |
112
|
|
|
break; |
113
|
|
|
case 'experience': |
114
|
|
|
break; |
115
|
|
|
case 'essential_skills': |
116
|
|
|
break; |
117
|
|
|
case 'asset_skills': |
118
|
|
|
break; |
119
|
|
|
case 'preview': |
120
|
|
|
break; |
121
|
|
|
default: |
122
|
|
|
$status = 'error'; |
123
|
|
|
break; |
124
|
|
|
} |
125
|
|
|
return $status; |
126
|
|
|
} |
127
|
|
|
} |
128
|
|
|
|