Issues (350)

app/Models/Skills/Skill.php (1 issue)

Severity
1
<?php
2
3
namespace App\Models\Skills;
4
5
use App\Models\EvaluationType;
6
use App\Models\Level;
7
use Backpack\CRUD\app\Models\Traits\CrudTrait;
8
use Illuminate\Database\Eloquent\Model;
9
10
/**
11
 * @mixin IdeHelperSkill
12
 */
13
class Skill extends Model
14
{
15
    use CrudTrait;
0 ignored issues
show
The trait Backpack\CRUD\app\Models\Traits\CrudTrait requires some properties which are not provided by App\Models\Skills\Skill: $fakeColumns, $identifiableAttribute, $Type
Loading history...
16
17
    protected $guarded = ['id'];
18
19
    protected $with = ['level', 'skill_type'];
20
21
    protected $appends = ['complete_name'];
22
23
    /** The category the skill belongs to */
24
    public function skill_type()
25
    {
26
        return $this->belongsTo(SkillType::class);
27
    }
28
29
    /** A skill belongs to a level, this allows to filter available skills when attaching them to courses */
30
    public function level()
31
    {
32
        return $this->belongsTo(Level::class);
33
    }
34
35
    /** A skill is linked to skill evaluations (themselves linked to enrollments) */
36
    public function skill_evaluations()
37
    {
38
        return $this->hasMany(SkillEvaluation::class);
39
    }
40
41
    public function presets()
42
    {
43
        return $this->morphToMany(EvaluationType::class, 'presettable', 'evaluation_type_presets');
44
    }
45
46
    public function getCompleteNameAttribute(): string
47
    {
48
        return '['.($this->level->name ?? '').'] '.($this->skill_type->shortname ?? '').' - '.$this->name ?? '';
49
    }
50
}
51