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
+29
View File
@@ -34,4 +34,33 @@ class ExamMemberRank extends Model
public $belongsTo = [
'member_rank' => 'GermanAirlinesVa\Schooling\Models\MemberRank',
];
public $belongsToMany = [
'exam_questions' => [
'GermanAirlinesVa\Schooling\Models\ExamMemberRankQuestion',
'table' => 'exam_exam_answer_exam_question',
'key' => 'exam_id',
'otherKey' => 'exam_question_id',
],
'exam_answers' => [
'GermanAirlinesVa\Schooling\Models\ExamMemberRankAnswer',
'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_member_rank_member_rank_id', function ($builder) {
$builder->where('member_rank_id', '<>', null);
});
}
}