You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.0 KiB
80 lines
2.0 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | Niucloud-admin 企业快速开发的多应用管理平台
|
|
// +----------------------------------------------------------------------
|
|
// | 官方网址:https://www.niucloud.com
|
|
// +----------------------------------------------------------------------
|
|
// | niucloud团队 版权所有 开源版本可自由商用
|
|
// +----------------------------------------------------------------------
|
|
// | Author: Niucloud Team
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\model\exam_answers;
|
|
|
|
use core\base\BaseModel;
|
|
use think\model\concern\SoftDelete;
|
|
use think\model\relation\HasMany;
|
|
use think\model\relation\HasOne;
|
|
|
|
use app\model\campus\Campus;
|
|
|
|
use app\model\personnel\Personnel;
|
|
|
|
use app\model\exam_questions\ExamQuestions;
|
|
|
|
/**
|
|
* 答题记录模型
|
|
* Class ExamAnswers
|
|
* @package app\model\exam_answers
|
|
*/
|
|
class ExamAnswers extends BaseModel
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
* 数据表主键
|
|
* @var string
|
|
*/
|
|
protected $pk = 'id';
|
|
|
|
/**
|
|
* 模型名称
|
|
* @var string
|
|
*/
|
|
protected $name = 'exam_answers';
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
* 搜索器:答题记录校区
|
|
* @param $value
|
|
* @param $data
|
|
*/
|
|
public function searchCampusIdAttr($query, $value, $data)
|
|
{
|
|
if ($value) {
|
|
$query->where("campus_id", $value);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function campus(){
|
|
return $this->hasOne(Campus::class, 'id', 'campus_id')->joinType('left')->withField('campus_name,id')->bind(['campus_id_name'=>'campus_name']);
|
|
}
|
|
|
|
public function personnel(){
|
|
return $this->hasOne(Personnel::class, 'id', 'user_id')->joinType('left')->withField('name,id')->bind(['user_id_name'=>'name']);
|
|
}
|
|
|
|
public function examQuestions(){
|
|
return $this->hasOne(ExamQuestions::class, 'id', 'question_id')->joinType('left')->withField('title,id')->bind(['question_id_name'=>'title']);
|
|
}
|
|
|
|
}
|
|
|