|
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; |
|
|
|
|
|
|
32
|
|
|
use HasTranslations; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @var $casts string[] |
|
|
|
|
|
|
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[] |
|
|
|
|
|
|
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[] |
|
|
|
|
|
|
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
|
|
|
|