Forms_Laravel/app/Models/Question.php

34 lines
693 B
PHP
Raw Permalink Normal View History

2024-07-15 06:24:05 +00:00
<?php
namespace App\Models;
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
{
use SoftDeletes;
2024-07-15 06:24:05 +00:00
use HasFactory;
protected $fillable = ['form_id', 'type', 'question_text', 'options', 'required'];
2024-07-15 06:24:05 +00:00
protected $casts = [
'options' => 'array',
'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);
}
}