Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| Question | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| brand | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| answers | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Models; |
| 4 | |
| 5 | use App\Enums\QuestionType; |
| 6 | use Illuminate\Database\Eloquent\Factories\HasFactory; |
| 7 | use Illuminate\Database\Eloquent\Model; |
| 8 | use Kwaadpepper\Enum\Traits\CastsEnums; |
| 9 | |
| 10 | class 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 | } |