Exam Question/Answer 3-way m:n

This commit is contained in:
2021-08-13 21:07:55 +02:00
parent aa073a5029
commit 837d86ae21
17 changed files with 226 additions and 51 deletions
+27 -1
View File
@@ -32,10 +32,36 @@ class ExamTyperatingQuestion extends Model
];
public $hasMany = [
'exam_answers' => 'GermanAirlinesVa\Schooling\Models\ExamTyperatingAnswer',
'exam_answers' => [
'GermanAirlinesVa\Schooling\Models\ExamTyperatingAnswer',
'key' => 'exam_question_id',
],
];
public $belongsTo = [
'typerating' => 'GermanAirlinesVa\Schooling\Models\Typerating',
];
public $belongsToMany = [
'exam_typeratings' => [
'GermanAirlinesVa\Schooling\Models\ExamTyperating',
'table' => 'exam_exam_answer_exam_question',
'key' => 'exam_question_id',
'otherKey' => 'exam_id',
],
];
/**
* The "booting" method of the model.
*
* @return void
*/
protected static function boot()
{
parent::boot();
static::addGlobalScope('exam_typerating_question_typerating_id', function ($builder) {
$builder->where('typerating_id', '<>', null);
});
}
}