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
|
|
|
]; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Mutator for criterion_id. Save NULL instead of empty strings. |
33
|
|
|
* |
34
|
|
|
* @param string|null $value Criterion Id, or empty string |
|
|
|
|
35
|
|
|
* @return void |
36
|
|
|
*/ |
37
|
|
|
public function setCriterionIdAttribute($value): void |
|
|
|
|
38
|
|
|
{ |
39
|
|
|
if (empty($value)) { // will check for empty string, null values |
|
|
|
|
40
|
|
|
$this->attributes['criterion_id'] = null; |
41
|
|
|
} else { |
42
|
|
|
$this->attributes['criterion_id'] = $value; |
43
|
|
|
} |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Get the RatingGuideQuestion relation. |
48
|
|
|
* |
49
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
50
|
|
|
*/ |
51
|
|
|
public function rating_guide_question(): \Illuminate\Database\Eloquent\Relations\BelongsTo |
|
|
|
|
52
|
|
|
{ |
53
|
|
|
return $this->belongsTo(\App\Models\RatingGuideQuestion::class); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Get the Criteria relation. |
58
|
|
|
* |
59
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
60
|
|
|
*/ |
61
|
|
|
public function criterion(): \Illuminate\Database\Eloquent\Relations\BelongsTo |
62
|
|
|
{ |
63
|
|
|
return $this->belongsTo(\App\Models\Criteria::class, 'criterion_id'); |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|