Completed
Pull Request — dev (#319)
by Tristan
07:50
created

SkillDeclaration::skill()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 2
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
/**
4
 * Created by Reliese Model.
5
 * Date: Thu, 12 Jul 2018 22:39:28 +0000.
6
 */
0 ignored issues
show
Coding Style introduced by
Missing @link tag in file comment
Loading history...
Coding Style introduced by
Missing @category tag in file comment
Loading history...
Coding Style introduced by
Missing @author tag in file comment
Loading history...
Coding Style introduced by
PHP version not specified
Loading history...
Coding Style introduced by
Missing @package tag in file comment
Loading history...
Coding Style introduced by
Missing @license tag in file comment
Loading history...
7
8
namespace App\Models;
9
use App\Models\Reference;
10
use App\Models\WorkSample;
11
use App\Models\WorkExperience;
12
13
/**
14
 * Class SkillDeclaration
15
 *
16
 * @property int $id
17
 * @property int $skill_id
18
 * @property int $skill_status_id
19
 * @property int $skill_level_id
20
 * @property int $applicant_id
21
 * @property string $description
22
 * @property \Jenssegers\Date\Date $created_at
23
 * @property \Jenssegers\Date\Date $updated_at
24
 *
25
 * @property \App\Models\Skill $skill
26
 * @property \App\Models\Lookup\SkillStatus $skill_status
27
 * @property \App\Models\Lookup\SkillLevel $skill_level
28
 * @property \App\Models\Applicant $applicant
29
 * @property \Illuminate\Database\Eloquent\Collection $references
30
 * @property \Illuminate\Database\Eloquent\Collection $work_samples
31
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @author tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
32
class SkillDeclaration extends BaseModel {
0 ignored issues
show
Coding Style introduced by
Opening brace of a class must be on the line after the definition
Loading history...
33
34
    protected $casts = [
35
        'skill_id' => 'int',
36
        'skill_status_id' => 'int',
37
        'skill_level_id' => 'int',
38
        'applicant_id' => 'int',
39
        'description' => 'string'
40
    ];
41
    protected $fillable = [
42
        'description',
43
        'skill_level_id'
44
    ];
45
46
    public function skill() {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function skill()
Loading history...
47
        return $this->belongsTo(\App\Models\Skill::class);
48
    }
49
50
    public function skill_status() {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function skill_status()
Loading history...
Coding Style introduced by
Public method name "SkillDeclaration::skill_status" is not in camel caps format
Loading history...
51
        return $this->belongsTo(\App\Models\Lookup\SkillStatus::class);
52
    }
53
54
    public function skill_level() {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function skill_level()
Loading history...
Coding Style introduced by
Public method name "SkillDeclaration::skill_level" is not in camel caps format
Loading history...
55
        return $this->belongsTo(\App\Models\Lookup\SkillLevel::class);
56
    }
57
58
    public function applicant() {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function applicant()
Loading history...
59
        return $this->belongsTo(\App\Models\Applicant::class);
60
    }
61
62
    public function references() {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function references()
Loading history...
63
        return $this->belongsToMany(\App\Models\Reference::class);
64
    }
65
66
    public function work_samples() {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function work_samples()
Loading history...
Coding Style introduced by
Public method name "SkillDeclaration::work_samples" is not in camel caps format
Loading history...
67
        return $this->belongsToMany(\App\Models\WorkSample::class);
68
    }
69
70
    // public function getWorkExperiencesAttribute() {
71
    //     // Retrieve all work experiences belonging to the same applicant and skill
72
    //     // as this object
73
    //     $skill_id = $this->skill->id;
74
    //     return WorkExperience::where('applicant_id', $this->applcant_id)
75
    //         ->whereHas('skills', function($query) use ($skill_id){
76
    //             $query->where('skills.id', $skill_id);
77
    //         })->get();
78
    // }
79
    //
80
    // public function getReferencesAttribute() {
81
    //     // Retrieve all references belonging to the same applicant and skill
82
    //     // as this object
83
    //     $skill_id = $this->skill->id;
84
    //     return Reference::where('applicant_id', $this->applcant_id)
85
    //         ->whereHas('skills', function($query) use ($skill_id){
86
    //             $query->where('skills.id', $skill_id);
87
    //         })->get();
88
    //     // $skill_id = $this->skill->id;
89
    //     // return $this->hasManyThrough(\App\Models\Reference::class,\App\Models\Applicant::class)
90
    //     //     ->whereHas('skills', function($query) use ($skill_id){
91
    //     //         $query->where('skills.id', $skill_id);
92
    //     //     })->get();
93
    // }
94
    //
95
    // public function getWorkSamplesAttribute() {
96
    //     // Retrieve all work samples belonging to the same applicant and skill
97
    //     // as this object
98
    //     $skill_id = $this->skill->id;
99
    //     return WorkSample::where('applicant_id', $this->applcant_id)
100
    //         ->whereHas('skills', function($query) use ($skill_id){
101
    //             $query->where('skills.id', $skill_id);
102
    //         })->get();
103
    // }
104
105
}
106