2024-07-15 06:24:05 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
2024-07-24 19:41:19 +00:00
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
2024-07-15 06:24:05 +00:00
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
class Question extends Model
|
|
|
|
{
|
2024-07-24 19:41:19 +00:00
|
|
|
use SoftDeletes;
|
2024-07-15 06:24:05 +00:00
|
|
|
use HasFactory;
|
2024-07-24 19:41:19 +00:00
|
|
|
protected $fillable = ['form_id', 'type', 'question_text', 'options', 'required'];
|
2024-07-15 06:24:05 +00:00
|
|
|
|
|
|
|
protected $casts = [
|
|
|
|
'options' => 'array',
|
2024-07-24 19:41:19 +00:00
|
|
|
'required' => 'boolean',
|
2024-07-15 06:24:05 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
public function form()
|
|
|
|
{
|
|
|
|
return $this->belongsTo(Form::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function responses()
|
|
|
|
{
|
|
|
|
return $this->hasMany(Response::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function user()
|
|
|
|
{
|
|
|
|
return $this->belongsTo(User::class);
|
|
|
|
}
|
|
|
|
}
|