14 lines
622 B
PHP
14 lines
622 B
PHP
<?php
|
|
namespace App\Models;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
class Question extends Model {
|
|
protected $fillable = ['subject_id','question_text','type','difficulty','points_value','active'];
|
|
protected $casts = ['active' => 'boolean'];
|
|
public function subject() { return $this->belongsTo(Subject::class); }
|
|
public function answerOptions() { return $this->hasMany(AnswerOption::class)->orderBy('sort_order'); }
|
|
public function attempts() { return $this->hasMany(QuestionAttempt::class); }
|
|
public function difficultyStars(): string {
|
|
return str_repeat('⭐', $this->difficulty);
|
|
}
|
|
}
|