Test Failed
Push — feature/job-builder/update-job... ( 68ba7e...7a08dc )
by Xander
23:02 queued 10:32
created

Skill::classifications()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
/**
4
 * Created by Reliese Model.
5
 * Date: Thu, 12 Jul 2018 22:39:27 +0000.
6
 */
7
8
namespace App\Models;
9
10
use \Backpack\CRUD\CrudTrait;
11
use \Backpack\CRUD\ModelTraits\SpatieTranslatable\HasTranslations;
12
13
/**
14
 * Class Skill
15
 *
16
 * @property int $id
17
 * @property string $name
18
 * @property string $description
19
 * @property int $skill_type_id
20
 * @property boolean $is_culture_skill
21
 * @property boolean $is_future_skill
22
 * @property \Jenssegers\Date\Date $created_at
23
 * @property \Jenssegers\Date\Date $updated_at
24
 *
25
 * @property \App\Models\Lookup\SkillType $skill_type
26
 * @property \Illuminate\Database\Eloquent\Collection $skill_declarations
27
 * @property \Illuminate\Database\Eloquent\Collection $classifications
28
 */
29
class Skill extends BaseModel
30
{
31
    use CrudTrait;
0 ignored issues
show
introduced by
The trait Backpack\CRUD\CrudTrait requires some properties which are not provided by App\Models\Skill: $Type, $fakeColumns
Loading history...
32
    use HasTranslations;
33
34
    /**
35
     * @var $casts string[]
0 ignored issues
show
Documentation Bug introduced by
The doc comment $casts at position 0 could not be parsed: Unknown type name '$casts' at position 0 in $casts.
Loading history...
36
     * */
37
    protected $casts = [
38
        'skill_type_id' => 'int',
39
        'is_culture_skill' => 'boolean',
40
        'is_future_skill' => 'boolean',
41
    ];
42
    /**
43
     * @var $fillable string[]
0 ignored issues
show
Documentation Bug introduced by
The doc comment $fillable at position 0 could not be parsed: Unknown type name '$fillable' at position 0 in $fillable.
Loading history...
44
     * */
45
    protected $fillable = [
46
        'name',
47
        'description',
48
        'skill_type_id',
49
        'is_culture_skill',
50
        'is_future_skill',
51
        'classifications'
52
    ];
53
    /**
54
     * @var $translatable string[]
0 ignored issues
show
Documentation Bug introduced by
The doc comment $translatable at position 0 could not be parsed: Unknown type name '$translatable' at position 0 in $translatable.
Loading history...
55
     * */
56
    public $translatable = [
57
        'name',
58
        'description',
59
    ];
60
61 5
    public function skill_type() // phpcs:ignore
62
    {
63 5
        return $this->belongsTo(\App\Models\Lookup\SkillType::class);
64
    }
65
66
    public function skill_declarations() // phpcs:ignore
67
    {
68
        return $this->hasMany(\App\Models\SkillDeclaration::class);
69
    }
70
71 1
    public function classifications() // phpcs:ignore
72
    {
73 1
        return $this->belongsToMany(\App\Models\Classification::class)->withTimestamps();
74
    }
75
76
    /**
77
     * Override the toArray() method to return the localized properties for
78
     * name and description. This was causing issues for ajax responses.
79
     *
80
     * @return mixed[]
81
     */
82 4
    public function toArray() : array
83
    {
84 4
        $array = parent::toArray();
85 4
        $array['name'] = $this->name;
86 4
        $array['description'] = $this->description;
87 4
        return $array;
88
    }
89
}
90