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