Passed
Push — feature/screening-plan-redux ( e0365f...910817 )
by Tristan
08:28
created

RatingGuideAnswer::criterion()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
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 3
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
namespace App\Models;
4
5
/**
6
 * Class RatingGuideQuestion
7
 *
8
 * @property int $id
9
 * @property int $rating_guide_question_id
10
 * @property int $criterion_id
11
 * @property string $expected_answer
12
 * @property \Jenssegers\Date\Date $created_at
13
 * @property \Jenssegers\Date\Date $updated_at
14
 *
15
 * @property \App\Models\RatingGuideQuestion $rating_guide_question
16
 * @property \App\Models\Criteria $criterion
17
 */
18
class RatingGuideAnswer extends BaseModel
19
{
20
    /**
21
     * The columns that can be filled with mass-assignment
22
     *
23
     * @var string[]
24
     */
25
    protected $fillable = [
26
        'rating_guide_question_id',
27
        'criterion_id',
28
        'expected_answer',
29
        'question'
30
    ];
31
32
    /**
33
     * Mutator for criterion_id. Save NULL instead of empty strings.
34
     *
35
     * @param string $value Criterion Id, or empty string
1 ignored issue
show
Coding Style Documentation introduced by
Parameter comment must end with a full stop
Loading history...
36
     * @return void
37
     */
38
    public function setCriterionIdAttribute(string $value): void
39
    {
40
        if (empty($value)) { // will check for empty string, null values
41
            $this->attributes['criterion_id'] = null;
42
        } else {
43
            $this->attributes['criterion_id'] = $value;
44
        }
45
    }
46
47
    /**
48
     * Get the RatingGuideQuestion relation.
49
     *
50
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
51
     */
52
    public function rating_guide_question(): \Illuminate\Database\Eloquent\Relations\BelongsTo
0 ignored issues
show
Coding Style introduced by
Method name "RatingGuideAnswer::rating_guide_question" is not in camel caps format
Loading history...
53
    {
54
        return $this->belongsTo(\App\Models\RatingGuideQuestion::class);
55
    }
56
57
    /**
58
     * Get the Criteria relation.
59
     *
60
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
61
     */
62
    public function criterion(): \Illuminate\Database\Eloquent\Relations\BelongsTo
63
    {
64
        return $this->belongsTo(\App\Models\Criteria::class, 'criterion_id');
65
    }
66
}
67