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\WorkSample; |
10
|
|
|
use Illuminate\Database\Eloquent\Collection; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class Applicant |
14
|
|
|
* |
15
|
|
|
* @property int $id |
16
|
|
|
* @property string $personal_website |
17
|
|
|
* @property string $tagline |
18
|
|
|
* @property string $twitter_username |
19
|
|
|
* @property string $linkedin_url |
20
|
|
|
* @property int $user_id |
21
|
|
|
* @property boolean $is_snapshot |
22
|
|
|
* |
23
|
|
|
* @property \Jenssegers\Date\Date $created_at |
24
|
|
|
* @property \Jenssegers\Date\Date $updated_at |
25
|
|
|
* |
26
|
|
|
* @property \App\Models\User $user |
27
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $applicant_profile_answers |
28
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $job_applications |
29
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $degrees |
30
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $courses |
31
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $work_experiences |
32
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $skill_declarations |
33
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $references |
34
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $work_samples |
35
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $projects |
36
|
|
|
*/ |
|
|
|
|
37
|
|
|
class Applicant extends BaseModel { |
|
|
|
|
38
|
|
|
|
39
|
|
|
protected $casts = [ |
40
|
|
|
'user_id' => 'int', |
41
|
|
|
'personal_website' => 'string', |
42
|
|
|
'tagline' => 'string', |
43
|
|
|
'twitter_username' => 'string', |
44
|
|
|
'linkedin_url' => 'string', |
45
|
|
|
'is_snapshot' => 'boolean' |
46
|
|
|
]; |
47
|
|
|
protected $fillable = [ |
48
|
|
|
'personal_website', |
49
|
|
|
'tagline', |
50
|
|
|
'twitter_username', |
51
|
|
|
'linkedin_url' |
52
|
|
|
]; |
53
|
|
|
|
54
|
|
|
public function user() { |
|
|
|
|
55
|
|
|
return $this->belongsTo(\App\Models\User::class); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function applicant_profile_answers() { |
|
|
|
|
59
|
|
|
return $this->hasMany(\App\Models\ApplicantProfileAnswer::class); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function job_applications() { |
|
|
|
|
63
|
|
|
if ($this->is_snapshot) { |
64
|
|
|
return $this->hasMany(\App\Models\JobApplication::class, 'applicant_snapshot_id'); |
65
|
|
|
} |
66
|
|
|
return $this->hasMany(\App\Models\JobApplication::class); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function degrees() { |
|
|
|
|
70
|
|
|
return $this->hasMany(\App\Models\Degree::class); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function courses() { |
|
|
|
|
74
|
|
|
return $this->hasMany(\App\Models\Course::class); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function work_experiences() { |
|
|
|
|
78
|
|
|
return $this->hasMany(\App\Models\WorkExperience::class); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
public function skill_declarations() { |
|
|
|
|
82
|
|
|
return $this->hasMany(\App\Models\SkillDeclaration::class); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function references() { |
|
|
|
|
86
|
|
|
return $this->hasMany(\App\Models\Reference::class); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
public function work_samples() { |
|
|
|
|
90
|
|
|
return $this->hasMany(\App\Models\WorkSample::class); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
public function projects() { |
|
|
|
|
94
|
|
|
return $this->hasMany(\App\Models\Project::class); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
//Accessors |
98
|
|
|
|
99
|
|
|
// Always return profile answers in the order the questions appear in |
100
|
|
|
// public function getApplicantProfileAnswersAttribute($applicant_profile_answers) { |
101
|
|
|
// debugbar()->debug($applicant_profile_answers); |
102
|
|
|
// if ($applicant_profile_answers !== null) { |
103
|
|
|
// return $applicant_profile_answers->sortBy(function ($answer){ |
104
|
|
|
// return $answer->applicant_profile_question->id; |
105
|
|
|
// }); |
106
|
|
|
// } else { |
107
|
|
|
// return collect($applicant_profile_answers); |
108
|
|
|
// } |
109
|
|
|
// } |
110
|
|
|
} |
111
|
|
|
|