|
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
|
|
|
|
|
10
|
|
|
use App\Events\JobSaved; |
|
11
|
|
|
use Illuminate\Notifications\Notifiable; |
|
12
|
|
|
use Jenssegers\Date\Date; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Class JobPoster |
|
16
|
|
|
* |
|
17
|
|
|
* @property int $id |
|
18
|
|
|
* @property int $job_term_id |
|
19
|
|
|
* @property int $term_qty |
|
20
|
|
|
* @property \Jenssegers\Date\Date $open_date_time |
|
21
|
|
|
* @property \Jenssegers\Date\Date $close_date_time |
|
22
|
|
|
* @property \Jenssegers\Date\Date $start_date_time |
|
23
|
|
|
* @property int $department_id |
|
24
|
|
|
* @property int $province_id |
|
25
|
|
|
* @property int $salary_min |
|
26
|
|
|
* @property int $salary_max |
|
27
|
|
|
* @property int $noc |
|
28
|
|
|
* @property string $classification |
|
29
|
|
|
* @property int $security_clearance_id |
|
30
|
|
|
* @property int $language_requirement_id |
|
31
|
|
|
* @property int $manager_id |
|
32
|
|
|
* @property boolean $published |
|
33
|
|
|
* @property \Jenssegers\Date\Date $created_at |
|
34
|
|
|
* @property \Jenssegers\Date\Date $updated_at |
|
35
|
|
|
* |
|
36
|
|
|
* @property \App\Models\Lookup\Department $department |
|
37
|
|
|
* @property \App\Models\Lookup\JobTerm $job_term |
|
38
|
|
|
* @property \App\Models\Lookup\LanguageRequirement $language_requirement |
|
39
|
|
|
* @property \App\Models\Manager $manager |
|
40
|
|
|
* @property \App\Models\Lookup\Province $province |
|
41
|
|
|
* @property \App\Models\Lookup\SecurityClearance $security_clearance |
|
42
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $criteria |
|
43
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $job_applications |
|
44
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $job_poster_key_tasks |
|
45
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $job_poster_questions |
|
46
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $job_poster_translations |
|
47
|
|
|
* |
|
48
|
|
|
* Localized Properties: |
|
49
|
|
|
* @property string $city |
|
50
|
|
|
* @property string $title |
|
51
|
|
|
* @property string $impact |
|
52
|
|
|
* @property string $branch |
|
53
|
|
|
* @property string $division |
|
54
|
|
|
* @property string $education |
|
55
|
|
|
*/ |
|
|
|
|
|
|
56
|
|
|
class JobPoster extends BaseModel { |
|
|
|
|
|
|
57
|
|
|
|
|
58
|
|
|
use \Dimsav\Translatable\Translatable; |
|
|
|
|
|
|
59
|
|
|
use Notifiable; |
|
|
|
|
|
|
60
|
|
|
|
|
61
|
|
|
public $translatedAttributes = ['city', 'title', 'impact', 'branch', 'division', 'education']; |
|
62
|
|
|
protected $casts = [ |
|
63
|
|
|
'job_term_id' => 'int', |
|
64
|
|
|
'department_id' => 'int', |
|
65
|
|
|
'province_id' => 'int', |
|
66
|
|
|
'salary_min' => 'int', |
|
67
|
|
|
'salary_max' => 'int', |
|
68
|
|
|
'noc' => 'int', |
|
69
|
|
|
'security_clearance_id' => 'int', |
|
70
|
|
|
'language_requirement_id' => 'int', |
|
71
|
|
|
'manager_id' => 'int', |
|
72
|
|
|
'published' => 'boolean' |
|
73
|
|
|
]; |
|
74
|
|
|
protected $dates = [ |
|
75
|
|
|
'open_date_time', |
|
76
|
|
|
'close_date_time', |
|
77
|
|
|
'start_date_time' |
|
78
|
|
|
]; |
|
79
|
|
|
protected $fillable = [ |
|
80
|
|
|
'job_term_id', |
|
81
|
|
|
'term_qty', |
|
82
|
|
|
'open_date_time', |
|
83
|
|
|
'close_date_time', |
|
84
|
|
|
'start_date_time', |
|
85
|
|
|
'department_id', |
|
86
|
|
|
'province_id', |
|
87
|
|
|
'salary_min', |
|
88
|
|
|
'salary_max', |
|
89
|
|
|
'noc', |
|
90
|
|
|
'classification', |
|
91
|
|
|
'security_clearance_id', |
|
92
|
|
|
'language_requirement_id', |
|
93
|
|
|
'published' |
|
94
|
|
|
]; |
|
95
|
|
|
|
|
96
|
|
|
protected $dispatchesEvents = [ |
|
97
|
|
|
'saved' => JobSaved::class, |
|
98
|
|
|
]; |
|
99
|
|
|
|
|
100
|
|
|
public function department() { |
|
|
|
|
|
|
101
|
|
|
return $this->belongsTo(\App\Models\Lookup\Department::class); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
public function job_term() { |
|
|
|
|
|
|
105
|
|
|
return $this->belongsTo(\App\Models\Lookup\JobTerm::class); |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
public function language_requirement() { |
|
|
|
|
|
|
109
|
|
|
return $this->belongsTo(\App\Models\Lookup\LanguageRequirement::class); |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
public function manager() { |
|
|
|
|
|
|
113
|
|
|
return $this->belongsTo(\App\Models\Manager::class); |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
public function province() { |
|
|
|
|
|
|
117
|
|
|
return $this->belongsTo(\App\Models\Lookup\Province::class); |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
public function security_clearance() { |
|
|
|
|
|
|
121
|
|
|
return $this->belongsTo(\App\Models\Lookup\SecurityClearance::class); |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
public function criteria() { |
|
|
|
|
|
|
125
|
|
|
return $this->hasMany(\App\Models\Criteria::class); |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
public function job_applications() { |
|
|
|
|
|
|
129
|
|
|
return $this->hasMany(\App\Models\JobApplication::class); |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
public function job_poster_key_tasks() { |
|
|
|
|
|
|
133
|
|
|
return $this->hasMany(\App\Models\JobPosterKeyTask::class); |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
public function job_poster_questions() { |
|
|
|
|
|
|
137
|
|
|
return $this->hasMany(\App\Models\JobPosterQuestion::class); |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
public function job_poster_translations() { |
|
|
|
|
|
|
141
|
|
|
return $this->hasMany(\App\Models\JobPosterTranslation::class); |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
//Accessors |
|
145
|
|
|
|
|
146
|
|
|
public function getApplicantCountAttribute() { |
|
|
|
|
|
|
147
|
|
|
$applicant_count = $this->job_applications->whereNotIn('application_status.name', 'draft')->count(); |
|
148
|
|
|
debugbar()->info($applicant_count); |
|
149
|
|
|
return $applicant_count; |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
public function getDaysRemainingAttribute() { |
|
|
|
|
|
|
153
|
|
|
$days_remaining = $this->close_date_time->diffInDays(Date::now()); |
|
154
|
|
|
debugbar()->info($days_remaining); |
|
155
|
|
|
return $days_remaining; |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
} |
|
159
|
|
|
|