Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
Question
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 brand
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 answers
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace App\Models;
4
5use App\Enums\QuestionType;
6use Illuminate\Database\Eloquent\Factories\HasFactory;
7use Illuminate\Database\Eloquent\Model;
8
9/**
10 * @property integer                 $id                 Id.
11 * @property integer                 $brand_id           Foreign key Brand.
12 * @property string                  $question           Question.
13 * @property \App\Enums\QuestionType $type               Type de question.
14 * @property-read \Illuminate\Support\Carbon $created_at Created date.
15 * @property-read \Illuminate\Support\Carbon $updated_at Updated date.
16 *
17 * @property-read \App\Models\Answer $answer Answer BelongsTo relation.
18 * @property-read \App\Models\Brand  $brand Brand BelongsTo relation.
19 */
20class Question extends Model
21{
22    use HasFactory;
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    /**
36     * Map attribute names to enum classes.
37     *
38     * @var array
39     */
40    protected $casts = [
41        'type' => QuestionType::class,
42    ];
43
44    // * RELATIONS
45
46    /**
47     * Brand BelongsTo relation.
48     *
49     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
50     */
51    public function brand(): \Illuminate\Database\Eloquent\Relations\BelongsTo
52    {
53        return $this->belongsTo(Brand::class);
54    }
55
56    /**
57     * Answer Has many relation.
58     *
59     * @return \Illuminate\Database\Eloquent\Relations\HasMany
60     */
61    public function answers(): \Illuminate\Database\Eloquent\Relations\HasMany
62    {
63        return $this->hasMany(Answer::class);
64    }
65}