GermanAirlinesVA-Schooling/models/ExamMemberRankQuestion.php

68 lines
1.4 KiB
PHP

<?php namespace GermanAirlinesVa\Schooling\Models;
use Model;
/**
* Model
*/
class ExamMemberRankQuestion extends Model
{
use \October\Rain\Database\Traits\Validation;
/*
* Disable timestamps by default.
* Remove this line if timestamps are defined in the database table.
*/
public $timestamps = false;
/**
* @var string The database table used by the model.
*/
public $table = 'exam_questions';
protected $connection = 'germanairlinesva_schooling';
/**
* @var array Validation rules
*/
public $rules = [
'member_rank' => 'required',
'in_use' => 'required',
'mandatory' => 'required',
'text' => 'required',
];
public $hasMany = [
'exam_answers' => [
'GermanAirlinesVa\Schooling\Models\ExamMemberRankAnswer',
'key' => 'exam_question_id',
],
];
public $belongsTo = [
'member_rank' => 'GermanAirlinesVa\Schooling\Models\MemberRank',
];
public $belongsToMany = [
'exam_member_ranks' => [
'GermanAirlinesVa\Schooling\Models\ExamMemberRank',
'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_member_rank_question_member_rank_id', function ($builder) {
$builder->where('member_rank_id', '<>', null);
});
}
}