1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Created by Reliese Model. |
5
|
|
|
* Date: Thu, 12 Jul 2018 22:39:28 +0000. |
6
|
|
|
*/ |
|
|
|
|
7
|
|
|
|
8
|
|
|
namespace App\Models; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class SkillDeclaration |
12
|
|
|
* |
13
|
|
|
* @property int $id |
14
|
|
|
* @property int $skill_id |
15
|
|
|
* @property int $skill_status_id |
16
|
|
|
* @property int $skill_level_id |
17
|
|
|
* @property int $applicant_id |
18
|
|
|
* @property string $description |
19
|
|
|
* @property \Jenssegers\Date\Date $created_at |
20
|
|
|
* @property \Jenssegers\Date\Date $updated_at |
21
|
|
|
* |
22
|
|
|
* @property \App\Models\Skill $skill |
23
|
|
|
* @property \App\Models\Lookup\SkillStatus $skill_status |
24
|
|
|
* @property \App\Models\Lookup\SkillLevel $skill_level |
25
|
|
|
* @property \App\Models\Applicant $applicant |
26
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $work_experiences |
27
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $references |
28
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $work_samples |
29
|
|
|
*/ |
|
|
|
|
30
|
|
|
class SkillDeclaration extends BaseModel { |
|
|
|
|
31
|
|
|
|
32
|
|
|
protected $casts = [ |
33
|
|
|
'skill_id' => 'int', |
34
|
|
|
'skill_status_id' => 'int', |
35
|
|
|
'skill_level_id' => 'int', |
36
|
|
|
'applicant_id' => 'int', |
37
|
|
|
'description' => 'string' |
38
|
|
|
]; |
39
|
|
|
protected $fillable = [ |
40
|
|
|
'skill_level_id', |
41
|
|
|
'description', |
42
|
|
|
]; |
43
|
|
|
|
44
|
|
|
public function skill() { |
|
|
|
|
45
|
|
|
return $this->belongsTo(\App\Models\Skill::class); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function skill_status() { |
|
|
|
|
49
|
|
|
return $this->belongsTo(\App\Models\Lookup\SkillStatus::class); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function skill_level() { |
|
|
|
|
53
|
|
|
return $this->belongsTo(\App\Models\Lookup\SkillLevel::class); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function applicant() { |
|
|
|
|
57
|
|
|
return $this->belongsTo(\App\Models\Applicant::class); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function work_experiences() { |
|
|
|
|
61
|
|
|
$skill_id = $this->skill->id; |
62
|
|
|
return $this->applicant->work_experiences->filter( |
63
|
|
|
function($work_experience) use ($skill_id) { |
|
|
|
|
64
|
|
|
//Returns true if $work_experience is connected to a skill |
65
|
|
|
// that matches this skill declaration |
66
|
|
|
return $work_experience->skills->where(id, $skill_id) != null; |
|
|
|
|
67
|
|
|
}); |
|
|
|
|
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function references() { |
|
|
|
|
71
|
|
|
$skill_id = $this->skill->id; |
72
|
|
|
return $this->applicant->references->filter( |
73
|
|
|
function($reference) use ($skill_id) { |
|
|
|
|
74
|
|
|
//Returns true if $reference is connected to a skill |
75
|
|
|
// that matches this skill declaration |
76
|
|
|
return $reference->skills->where(id, $skill_id) != null; |
|
|
|
|
77
|
|
|
}); |
|
|
|
|
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function work_samples() { |
|
|
|
|
81
|
|
|
$skill_id = $this->skill->id; |
82
|
|
|
return $this->applicant->work_samples->filter( |
83
|
|
|
function($work_sample) use ($skill_id) { |
|
|
|
|
84
|
|
|
//Returns true if $reference is connected to a skill |
85
|
|
|
// that matches this skill declaration |
86
|
|
|
return $work_sample->skills->where(id, $skill_id) != null; |
|
|
|
|
87
|
|
|
}); |
|
|
|
|
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
} |
91
|
|
|
|