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

Skill   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A courses() 0 3 1
A skill_evaluations() 0 3 1
A level() 0 3 1
A skill_type() 0 3 1
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