Passed
Push — master ( 8c9d15...53e72a )
by Thomas
07:13
created

Skill::courses()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Models\Skills;
4
5
use App\Models\Course;
6
use App\Models\Level;
7
use Backpack\CRUD\app\Models\Traits\CrudTrait;
8
use Illuminate\Database\Eloquent\Model;
9
10
class Skill extends Model
11
{
12
    use CrudTrait;
0 ignored issues
show
introduced by
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...
13
    protected $guarded = ['id'];
14
    protected $with = ['level', 'skill_type'];
15
16
    /** The category the skill belongs to */
17
    public function skill_type()
18
    {
19
        return $this->belongsTo(SkillType::class);
20
    }
21
22
    /** A skill belongs to a level, this allows to filter available skills when attaching them to courses */
23
    public function level()
24
    {
25
        return $this->belongsTo(Level::class);
26
    }
27
28
    /** a skill has many courses, and a course has many skills
29
     * Skills are like "criteria" that will need to be evaluated during the course
30
     */
31
    public function courses()
32
    {
33
        return $this->belongsToMany(Course::class);
34
    }
35
36
    /** A skill is linked to skill evaluations (themselves linked to enrollments) */
37
    public function skill_evaluations()
38
    {
39
        return $this->hasMany(SkillEvaluation::class);
40
    }
41
}
42