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 App\Traits\Models\ActivityLog;
7use Illuminate\Database\Eloquent\Factories\HasFactory;
8use Illuminate\Database\Eloquent\Model;
9
10/**
11 * @property integer                 $id                 Id.
12 * @property integer                 $brand_id           Foreign key Brand.
13 * @property string                  $question           Question.
14 * @property \App\Enums\QuestionType $type               Type de question.
15 * @property-read \Illuminate\Support\Carbon $created_at Created date.
16 * @property-read \Illuminate\Support\Carbon $updated_at Updated date.
17 *
18 * @property-read \App\Models\Answer $answer Answer BelongsTo relation.
19 * @property-read \App\Models\Brand  $brand Brand BelongsTo relation.
20 */
21class Question extends Model
22{
23    use ActivityLog;
24    use HasFactory;
25
26    /**
27     * The attributes that are mass assignable.
28     *
29     * @var string[]
30     */
31    protected $fillable = [
32        'question',
33        'type',
34        'brand_id',
35    ];
36
37    /**
38     * Map attribute names to enum classes.
39     *
40     * @var array
41     */
42    protected $casts = [
43        'type' => QuestionType::class,
44    ];
45
46    // * RELATIONS
47
48    /**
49     * Brand BelongsTo relation.
50     *
51     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
52     */
53    public function brand(): \Illuminate\Database\Eloquent\Relations\BelongsTo
54    {
55        return $this->belongsTo(Brand::class);
56    }
57
58    /**
59     * Answer Has many relation.
60     *
61     * @return \Illuminate\Database\Eloquent\Relations\HasMany
62     */
63    public function answers(): \Illuminate\Database\Eloquent\Relations\HasMany
64    {
65        return $this->hasMany(Answer::class);
66    }
67}