Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
Question
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 2
6
0.00% covered (danger)
0.00%
0 / 1
 brand
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 answers
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace App\Models;
4
5use App\Enums\QuestionType;
6use Illuminate\Database\Eloquent\Factories\HasFactory;
7use Illuminate\Database\Eloquent\Model;
8use Kwaadpepper\Enum\Traits\CastsEnums;
9
10class Question extends Model
11{
12    use CastsEnums;
13    use HasFactory;
14
15    /**
16     * Map attribute names to enum classes.
17     *
18     * @var array
19     */
20    protected $enumCasts = [
21        'type' => QuestionType::class
22    ];
23
24    /**
25     * The attributes that are mass assignable.
26     *
27     * @var string[]
28     */
29    protected $fillable = [
30        'question',
31        'type',
32        'brand_id'
33    ];
34
35    // * RELATIONS
36
37    /**
38     * Brand BelongsTo relation
39     *
40     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
41     */
42    public function brand()
43    {
44        return $this->belongsTo(Brand::class);
45    }
46
47    /**
48     * Answer Has many relation
49     *
50     * @return \Illuminate\Database\Eloquent\Relations\HasMany
51     */
52    public function answers()
53    {
54        return $this->hasMany(Answer::class);
55    }
56}