2021-08-10 12:09:49 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use App\Enums\QuestionType;
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
use Kwaadpepper\Enum\Traits\CastsEnums;
|
|
|
|
|
|
|
|
|
|
class Question extends Model
|
|
|
|
|
{
|
|
|
|
|
use CastsEnums;
|
|
|
|
|
use HasFactory;
|
|
|
|
|
|
2021-12-19 15:57:24 +01:00
|
|
|
/**
|
|
|
|
|
* Map attribute names to enum classes.
|
|
|
|
|
*
|
|
|
|
|
* @var array
|
|
|
|
|
*/
|
2021-08-10 12:09:49 +02:00
|
|
|
protected $enumCasts = [
|
|
|
|
|
'type' => QuestionType::class
|
|
|
|
|
];
|
|
|
|
|
|
2021-12-19 15:57:24 +01:00
|
|
|
/**
|
|
|
|
|
* The attributes that are mass assignable.
|
|
|
|
|
*
|
|
|
|
|
* @var string[]
|
|
|
|
|
*/
|
2021-08-10 12:09:49 +02:00
|
|
|
protected $fillable = [
|
|
|
|
|
'question',
|
2022-12-01 17:35:21 +01:00
|
|
|
'type',
|
|
|
|
|
'brand_id'
|
2021-08-10 12:09:49 +02:00
|
|
|
];
|
|
|
|
|
|
2021-12-19 15:57:24 +01:00
|
|
|
// * RELATIONS
|
|
|
|
|
|
2021-08-10 12:09:49 +02:00
|
|
|
/**
|
|
|
|
|
* Brand BelongsTo relation
|
|
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
|
|
|
*/
|
|
|
|
|
public function brand()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(Brand::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2022-03-22 11:47:58 +01:00
|
|
|
* Answer Has many relation
|
2021-08-10 12:09:49 +02:00
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
|
|
|
|
*/
|
|
|
|
|
public function answers()
|
|
|
|
|
{
|
|
|
|
|
return $this->hasMany(Answer::class);
|
|
|
|
|
}
|
|
|
|
|
}
|