Passed
Push — feature/job-status-notificatio... ( 0278a2...e12c98 )
by Chris
09:02 queued 04:34
created

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