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\Models\WorkSample; |
11
|
|
|
use Illuminate\Database\Eloquent\Collection; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Class Applicant |
15
|
|
|
* |
16
|
|
|
* @property int $id |
17
|
|
|
* @property string $personal_website |
18
|
|
|
* @property string $tagline |
19
|
|
|
* @property string $twitter_username |
20
|
|
|
* @property string $linkedin_url |
21
|
|
|
* @property int $user_id |
22
|
|
|
* @property boolean $is_snapshot |
23
|
|
|
* |
24
|
|
|
* @property \Jenssegers\Date\Date $created_at |
25
|
|
|
* @property \Jenssegers\Date\Date $updated_at |
26
|
|
|
* |
27
|
|
|
* @property \App\Models\User $user |
28
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $applicant_profile_answers |
29
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $job_applications |
30
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $submitted_applications |
31
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $degrees |
32
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $courses |
33
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $work_experiences |
34
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $skill_declarations |
35
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $references |
36
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $work_samples |
37
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $projects |
38
|
|
|
*/ |
39
|
|
|
class Applicant extends BaseModel |
40
|
|
|
{ |
41
|
|
|
|
42
|
|
|
protected $casts = [ |
43
|
|
|
'user_id' => 'int', |
44
|
|
|
'personal_website' => 'string', |
45
|
|
|
'tagline' => 'string', |
46
|
|
|
'twitter_username' => 'string', |
47
|
|
|
'linkedin_url' => 'string', |
48
|
|
|
'is_snapshot' => 'boolean' |
49
|
|
|
]; |
50
|
|
|
protected $fillable = [ |
51
|
|
|
'personal_website', |
52
|
|
|
'tagline', |
53
|
|
|
'twitter_username', |
54
|
|
|
'linkedin_url' |
55
|
|
|
]; |
56
|
|
|
|
57
|
|
|
public function user() |
58
|
|
|
{ |
59
|
|
|
return $this->belongsTo(\App\Models\User::class); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function applicant_profile_answers() |
63
|
|
|
{ |
64
|
|
|
return $this->hasMany(\App\Models\ApplicantProfileAnswer::class); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function job_applications() |
68
|
|
|
{ |
69
|
|
|
if ($this->is_snapshot) { |
70
|
|
|
return $this->hasMany(\App\Models\JobApplication::class, 'applicant_snapshot_id'); |
71
|
|
|
} |
72
|
|
|
return $this->hasMany(\App\Models\JobApplication::class); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Get all of the Job Applications submitted by this applicant |
77
|
|
|
* |
78
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany |
79
|
|
|
*/ |
80
|
|
|
public function submitted_applications() // phpcs:ignore |
81
|
|
|
{ |
82
|
|
|
return $this->hasMany(\App\Models\JobApplication::class)->whereDoesntHave('application_status', function ($query): void { |
83
|
|
|
$query->where('name', 'draft'); |
84
|
|
|
}); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public function degrees() |
88
|
|
|
{ |
89
|
|
|
return $this->morphMany(\App\Models\Degree::class, 'degreeable')->orderBy('end_date', 'desc'); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public function courses() |
93
|
|
|
{ |
94
|
|
|
return $this->morphMany(\App\Models\Course::class, 'courseable')->orderBy('end_date', 'desc'); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
public function work_experiences() |
98
|
|
|
{ |
99
|
|
|
return $this->morphMany(\App\Models\WorkExperience::class, 'experienceable')->orderBy('end_date', 'desc'); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
public function skill_declarations() |
103
|
|
|
{ |
104
|
|
|
return $this->morphMany(\App\Models\SkillDeclaration::class, 'skillable'); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
public function references() |
108
|
|
|
{ |
109
|
|
|
return $this->morphMany(\App\Models\Reference::class, 'referenceable'); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
public function work_samples() |
113
|
|
|
{ |
114
|
|
|
return $this->morphMany(\App\Models\WorkSample::class, 'work_sampleable'); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
public function projects() |
118
|
|
|
{ |
119
|
|
|
return $this->morphMany(\App\Models\Project::class, 'projectable'); |
120
|
|
|
} |
121
|
|
|
} |
122
|
|
|
|