Passed
Push — task/refactor-application-data... ( 374eb4...2cf671 )
by Tristan
05:19 queued 11s
created

ExperienceAward::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
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
use App\Models\BaseModel;
6
7
/**
8
 * Class ExperienceAward
9
 *
10
 * @property int $id
11
 * @property string $title
12
 * @property int $award_recipient_type_id
13
 * @property string $issued_by
14
 * @property int $award_recognition_type_id
15
 * @property \Jenssegers\Date\Date $awarded_date
16
 * @property int $experienceable_id
17
 * @property string $experienceable_type
18
 * @property boolean $is_education_requirement
19
 * @property \Jenssegers\Date\Date $created_at
20
 * @property \Jenssegers\Date\Date $updated_at
21
 *
22
 * @property \App\Models\Applicant|\App\Models\JobApplication $experienceable
23
 * @property \App\Models\Lookup\AwardRecipientType $award_recipient_type
24
 * @property \App\Models\Lookup\AwardRecognitionType $award_recognition_type
25
 * @property \Illuminate\Database\Eloquent\Collection $skills
26
 * @property \Illuminate\Database\Eloquent\Collection $experience_skills
27
 *
28
 * @method string experienceTypeName
29
 */
30
class ExperienceAward extends BaseModel
31
{
32
    protected $casts = [
33
        'title' => 'string',
34
        'award_recipient_type_id' => 'int',
35
        'issued_by' => 'string',
36
        'award_recognition_type_id' => 'int',
37
        'awarded_date' => 'date',
38
        'is_education_requirement' => 'boolean'
39
    ];
40
41
    protected $fillable = [
42
        'title',
43
        'award_recipient_type_id',
44
        'issued_by',
45
        'award_recognition_type_id',
46
        'awarded_date',
47
        'is_education_requirement'
48
    ];
49
50
    protected $table = 'experiences_award';
51
52
    public static function boot()
53
    {
54
        parent::boot();
55
56
        // Delete associated ExperienceSkills when this is deleted.
57
        static::deleting(function ($award): void {
58
            foreach ($award->experience_skills as $es) {
59
                $es->delete();
60
            }
61
        });
62
    }
63
64
    public function award_recipient_type() //phpcs:ignore
65
    {
66
        return $this->belongsTo(\App\Models\Lookup\AwardRecipientType::class);
67
    }
68
69
    public function award_recognition_type() //phpcs:ignore
70
    {
71
        return $this->belongsTo(\App\Models\Lookup\AwardRecognitionType::class);
72
    }
73
74
    public function experienceable() //phpcs:ignore
75
    {
76
        return $this->morphTo();
77
    }
78
79
    public function experience_skills() //phpcs:ignore
80
    {
81
        return $this->morphMany(\App\Models\ExperienceSkill::class, 'experience');
82
    }
83
84
    /**
85
     * Returns the name of this experience type. Used to distinguish from other Experience models.
86
     * @return string Returns the string 'experience_award'.
87
     */
88
    public function experienceTypeName(): string
89
    {
90
        return 'experience_award';
91
    }
92
}
93