GermanAirlinesVA-Schooling/models/ExamTyperatingQuestion.php
2021-08-13 21:08:59 +02:00

65 lines
1.4 KiB
PHP

<?php namespace GermanAirlinesVa\Schooling\Models;
use Model;
/**
* Model
*/
class ExamTyperatingQuestion 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 = [
'typerating' => 'required',
'in_use' => 'required',
'mandatory' => 'required',
'text' => 'required',
];
public $hasMany = [
'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);
});
}
}