'decimal:2', 'sort' => 'integer', 'options' => 'array', ]; /** * The "booted" method of the model. */ protected static function booted(): void { static::creating(function (ExamQuestion $question) { // Handle sort if (is_null($question->sort)) { $question->sort = static::getNextSortValue(); } }); } public function exam(): BelongsTo { return $this->belongsTo(Exam::class); } public function question_options(): HasMany { return $this->hasMany(ExamQuestionOption::class)->orderBy('sort', 'asc'); } public function attempt_answers(): HasMany { return $this->hasMany(ExamAttemptAnswer::class); } }