Passed
Push — feature/application-experience... ( 15ccad...337d86 )
by Tristan
04:00
created

Skill::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
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 Backpack\CRUD\app\Models\Traits\CrudTrait;
6
use Backpack\CRUD\app\Models\Traits\SpatieTranslatable\HasTranslations;
7
8
/**
9
 * Class Skill
10
 *
11
 * @property int $id
12
 * @property string $name
13
 * @property string $description
14
 * @property int $skill_type_id
15
 * @property boolean $is_culture_skill
16
 * @property boolean $is_future_skill
17
 * @property \Jenssegers\Date\Date $created_at
18
 * @property \Jenssegers\Date\Date $updated_at
19
 *
20
 * @property \App\Models\Lookup\SkillType $skill_type
21
 * @property \Illuminate\Database\Eloquent\Collection $skill_declarations
22
 * @property \Illuminate\Database\Eloquent\Collection $classifications
23
 * @property \App\Models\ExperienceAward|\App\Models\ExperienceCommunity|\App\Models\ExperienceEducation|\App\Models\ExperiencePersonal|\App\Models\ExperienceWork $experience
24
 * @property \Illuminate\Database\Eloquent\Collection $experience_skills
25
 */
26
class Skill extends BaseModel
27
{
28
    use CrudTrait;
29
    use HasTranslations;
30
31
    protected $casts = [
32
        'skill_type_id' => 'int',
33
        'is_culture_skill' => 'boolean',
34
        'is_future_skill' => 'boolean',
35
    ];
36
37
    protected $fillable = [
38
        'name',
39
        'description',
40
        'skill_type_id',
41
        'is_culture_skill',
42
        'is_future_skill',
43
        'classifications'
44
    ];
45
46
    public $translatable = [
47
        'name',
48
        'description',
49
    ];
50
51
    public function skill_type() // phpcs:ignore
52
    {
53
        return $this->belongsTo(\App\Models\Lookup\SkillType::class);
54
    }
55
56
    public function skill_declarations() // phpcs:ignore
57
    {
58
        return $this->hasMany(\App\Models\SkillDeclaration::class);
59
    }
60
61
    public function classifications() // phpcs:ignore
62
    {
63
        return $this->belongsToMany(\App\Models\Classification::class)->withTimestamps();
64
    }
65
66
    // Version 2 application models.
67
68
    public function experiences_work() // phpcs:ignore
69
    {
70
        return $this->morphedByMany(\App\Models\ExperienceWork::class, 'experience', 'experience_skills');
71
    }
72
73
    public function experiences_personal() // phpcs:ignore
74
    {
75
        return $this->morphedByMany(\App\Models\ExperiencePersonal::class, 'experience', 'experience_skills');
76
    }
77
78
    public function experiences_education() // phpcs:ignore
79
    {
80
        return $this->morphedByMany(\App\Models\ExperienceEducation::class, 'experience', 'experience_skills');
81
    }
82
83
    public function experiences_award() // phpcs:ignore
84
    {
85
        return $this->morphedByMany(\App\Models\ExperienceAward::class, 'experience', 'experience_skills');
86
    }
87
88
    public function experiences_community() // phpcs:ignore
89
    {
90
        return $this->morphedByMany(\App\Models\ExperienceCommunity::class, 'experience', 'experience_skills');
91
    }
92
93
    public function experience_skills() // phpcs:ignore
94
    {
95
        return $this->hasMany(\App\Models\ExperienceSkill::class);
96
    }
97
98
    /**
99
     * Check for a null "is_culture_skill" and pass false instead.
100
     *
101
     * @param mixed $value Incoming value for the "is_culture_skill" attribute.
102
     *
103
     * @return void
104
     */
105
    public function setIsCultureSkillAttribute($value): void
106
    {
107
        if ($value === null) {
108
            $value = false;
109
        }
110
        $this->attributes['is_culture_skill'] = $value;
0 ignored issues
show
Bug Best Practice introduced by
The property attributes does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
111
    }
112
113
    /**
114
     * Check for a null "is_future_skill" and pass false instead.
115
     *
116
     * @param mixed $value Incoming value for the "is_future_skill" attribute.
117
     *
118
     * @return void
119
     */
120
    public function setIsFutureSkillAttribute($value): void
121
    {
122
        if ($value === null) {
123
            $value = false;
124
        }
125
        $this->attributes['is_future_skill'] = $value;
0 ignored issues
show
Bug Best Practice introduced by
The property attributes does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
126
    }
127
}
128