Passed
Push — task/skill-skillcategory-relat... ( 8f6df1...d50b49 )
by Chris
04:37 queued 10s
created

Applicant::skills()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace App\Models;
4
5
use App\Traits\TalentCloudCrudTrait as CrudTrait;
6
7
/**
8
 * Class Applicant
9
 *
10
 * @property int $id
11
 * @property string $personal_website
12
 * @property string $tagline
13
 * @property string $twitter_username
14
 * @property string $linkedin_url
15
 * @property int $user_id
16
 * @property boolean $is_snapshot
17
 *
18
 * @property \Jenssegers\Date\Date $created_at
19
 * @property \Jenssegers\Date\Date $updated_at
20
 *
21
 * @property \App\Models\User $user
22
 * @property \Illuminate\Database\Eloquent\Collection $applicant_profile_answers
23
 * @property \Illuminate\Database\Eloquent\Collection $job_applications
24
 * @property \Illuminate\Database\Eloquent\Collection $submitted_applications
25
 * @property \Illuminate\Database\Eloquent\Collection $degrees
26
 * @property \Illuminate\Database\Eloquent\Collection $courses
27
 * @property \Illuminate\Database\Eloquent\Collection $work_experiences
28
 * @property \Illuminate\Database\Eloquent\Collection $skill_declarations
29
 * @property \Illuminate\Database\Eloquent\Collection $references
30
 * @property \Illuminate\Database\Eloquent\Collection $work_samples
31
 * @property \Illuminate\Database\Eloquent\Collection $projects
32
 * @property \Illuminate\Database\Eloquent\Collection $skills
33
 *
34
 * Version 2 application models.
35
 * @property \Illuminate\Database\Eloquent\Collection $experiences_work
36
 * @property \Illuminate\Database\Eloquent\Collection $experiences_personal
37
 * @property \Illuminate\Database\Eloquent\Collection $experiences_education
38
 * @property \Illuminate\Database\Eloquent\Collection $experiences_award
39
 * @property \Illuminate\Database\Eloquent\Collection $experiences_community
40
 */
41
class Applicant extends BaseModel
42
{
43
    // Trait for Backpack.
44
    use CrudTrait;
45
46
    protected $casts = [
47
        'user_id' => 'int',
48
        'personal_website' => 'string',
49
        'tagline' => 'string',
50
        'twitter_username' => 'string',
51
        'linkedin_url' => 'string',
52
        'is_snapshot' => 'boolean'
53
    ];
54
    protected $fillable = [
55
        'personal_website',
56
        'tagline',
57
        'twitter_username',
58
        'linkedin_url'
59
    ];
60
61
    public function user()
62
    {
63
        return $this->belongsTo(\App\Models\User::class);
64
    }
65
66
    public function applicant_profile_answers() //phpcs:ignore
67
    {
68
        return $this->hasMany(\App\Models\ApplicantProfileAnswer::class);
69
    }
70
71
    public function job_applications() //phpcs:ignore
72
    {
73
        if ($this->is_snapshot) {
74
            return $this->hasMany(\App\Models\JobApplication::class, 'applicant_snapshot_id');
75
        }
76
        return $this->hasMany(\App\Models\JobApplication::class);
77
    }
78
79
    /**
80
     * Get all of the Job Applications submitted by this applicant
81
     *
82
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
83
     */
84
    public function submitted_applications() // phpcs:ignore
85
    {
86
        return $this->hasMany(\App\Models\JobApplication::class)->whereDoesntHave('application_status', function ($query): void {
87
            $query->where('name', 'draft');
88
        });
89
    }
90
91
    public function degrees()
92
    {
93
        return $this->morphMany(\App\Models\Degree::class, 'degreeable')->orderBy('end_date', 'desc');
94
    }
95
96
    public function courses()
97
    {
98
        return $this->morphMany(\App\Models\Course::class, 'courseable')->orderBy('end_date', 'desc');
99
    }
100
101
    public function work_experiences() //phpcs:ignore
102
    {
103
        return $this->morphMany(\App\Models\WorkExperience::class, 'experienceable')->orderBy('end_date', 'desc');
104
    }
105
106
    public function skill_declarations() //phpcs:ignore
107
    {
108
        return $this->morphMany(\App\Models\SkillDeclaration::class, 'skillable');
109
    }
110
111
    public function references()
112
    {
113
        return $this->morphMany(\App\Models\Reference::class, 'referenceable');
114
    }
115
116
    public function work_samples() //phpcs:ignore
117
    {
118
        return $this->morphMany(\App\Models\WorkSample::class, 'work_sampleable');
119
    }
120
121
    public function projects()
122
    {
123
        return $this->morphMany(\App\Models\Project::class, 'projectable');
124
    }
125
126
    public function skills() // phpcs:ignore
127
    {
128
        return $this->belongsToMany(\App\Models\Skill::class, 'applicant_skill');
129
    }
130
131
    // Version 2 application models.
132
133
    public function experiences_work() //phpcs:ignore
134
    {
135
        return $this->morphMany(\App\Models\ExperienceWork::class, 'experienceable')
136
            ->orderBy('end_date', 'desc');
137
    }
138
139
    public function experiences_personal() //phpcs:ignore
140
    {
141
        return $this->morphMany(\App\Models\ExperiencePersonal::class, 'experienceable')
142
            ->orderBy('end_date', 'desc');
143
    }
144
145
    public function experiences_education() //phpcs:ignore
146
    {
147
        return $this->morphMany(\App\Models\ExperienceEducation::class, 'experienceable')
148
            ->orderBy('end_date', 'desc');
149
    }
150
151
    public function experiences_award() //phpcs:ignore
152
    {
153
        return $this->morphMany(\App\Models\ExperienceAward::class, 'experienceable');
154
    }
155
156
    public function experiences_community() //phpcs:ignore
157
    {
158
        return $this->morphMany(\App\Models\ExperienceCommunity::class, 'experienceable')
159
            ->orderBy('end_date', 'desc');
160
    }
161
}
162