54 lines
983 B
PHP
54 lines
983 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\QuestionType;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Question extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var string[]
|
|
*/
|
|
protected $fillable = [
|
|
'question',
|
|
'type',
|
|
'brand_id',
|
|
];
|
|
|
|
/**
|
|
* Map attribute names to enum classes.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $casts = [
|
|
'type' => QuestionType::class,
|
|
];
|
|
|
|
// * RELATIONS
|
|
|
|
/**
|
|
* Brand BelongsTo relation
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
*/
|
|
public function brand()
|
|
{
|
|
return $this->belongsTo(Brand::class);
|
|
}
|
|
|
|
/**
|
|
* Answer Has many relation
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
|
*/
|
|
public function answers()
|
|
{
|
|
return $this->hasMany(Answer::class);
|
|
}
|
|
}
|