Exam Question/Answer 3-way m:n
This commit is contained in:
@@ -34,4 +34,33 @@ class ExamTyperating extends Model
|
||||
public $belongsTo = [
|
||||
'typerating' => 'GermanAirlinesVa\Schooling\Models\Typerating',
|
||||
];
|
||||
|
||||
public $belongsToMany = [
|
||||
'exam_questions' => [
|
||||
'GermanAirlinesVa\Schooling\Models\ExamTyperatingQuestion',
|
||||
'table' => 'exam_exam_answer_exam_question',
|
||||
'key' => 'exam_id',
|
||||
'otherKey' => 'exam_question_id',
|
||||
],
|
||||
'exam_answers' => [
|
||||
'GermanAirlinesVa\Schooling\Models\ExamTyperatingAnswer',
|
||||
'table' => 'exam_exam_answer_exam_question',
|
||||
'key' => 'exam_id',
|
||||
'otherKey' => 'exam_answer_id',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* The "booting" method of the model.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::addGlobalScope('exam_typerating_typerating_id', function ($builder) {
|
||||
$builder->where('typerating_id', '<>', null);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user