47 lines
889 B
PHP
47 lines
889 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Question extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'quiz_id',
|
|
'subject_id',
|
|
'question_text',
|
|
'type',
|
|
'score',
|
|
'solution_explanation',
|
|
'order',
|
|
];
|
|
|
|
protected $casts = [
|
|
'score' => 'float',
|
|
'order' => 'integer',
|
|
];
|
|
|
|
public function quiz()
|
|
{
|
|
return $this->belongsTo(Quiz::class, 'quiz_id');
|
|
}
|
|
|
|
public function subject()
|
|
{
|
|
return $this->belongsTo(QuizSubject::class, 'subject_id');
|
|
}
|
|
|
|
public function options()
|
|
{
|
|
return $this->hasMany(QuestionOption::class, 'question_id');
|
|
}
|
|
|
|
public function userAnswers()
|
|
{
|
|
return $this->hasMany(UserQuizAnswer::class, 'question_id');
|
|
}
|
|
}
|