68 lines
1.5 KiB
PHP
68 lines
1.5 KiB
PHP
<?php namespace GermanAirlinesVa\Schooling\Models;
|
|
|
|
use Model;
|
|
|
|
/**
|
|
* Model
|
|
*/
|
|
class ExamMemberRank 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 = 'exams';
|
|
protected $connection = 'germanairlinesva_schooling';
|
|
|
|
/**
|
|
* @var array Validation rules
|
|
*/
|
|
public $rules = [
|
|
'member_id' => 'required',
|
|
'member_rank_id' => 'required',
|
|
'start' => 'required',
|
|
'status' => 'required',
|
|
];
|
|
|
|
public $belongsTo = [
|
|
'member_rank' => 'GermanAirlinesVa\Schooling\Models\MemberRank',
|
|
'member' => 'GermanAirlinesVa\Social\Models\Member',
|
|
];
|
|
|
|
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);
|
|
});
|
|
}
|
|
}
|