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.
97 lines
2.3 KiB
97 lines
2.3 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | Niucloud-admin 企业快速开发的多应用管理平台
|
|
// +----------------------------------------------------------------------
|
|
// | 官方网址:https://www.niucloud.com
|
|
// +----------------------------------------------------------------------
|
|
// | niucloud团队 版权所有 开源版本可自由商用
|
|
// +----------------------------------------------------------------------
|
|
// | Author: Niucloud Team
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\model\exam_questions;
|
|
|
|
use core\base\BaseModel;
|
|
use think\model\concern\SoftDelete;
|
|
use think\model\relation\HasMany;
|
|
use think\model\relation\HasOne;
|
|
|
|
/**
|
|
* 试题模型
|
|
* Class ExamQuestions
|
|
* @package app\model\exam_questions
|
|
*/
|
|
class ExamQuestions extends BaseModel
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
* 数据表主键
|
|
* @var string
|
|
*/
|
|
protected $pk = 'id';
|
|
|
|
/**
|
|
* 模型名称
|
|
* @var string
|
|
*/
|
|
protected $name = 'exam_questions';
|
|
|
|
|
|
|
|
// 设置json类型字段
|
|
protected $json = [ 'option_json' ];
|
|
|
|
// 设置JSON数据返回数组
|
|
protected $jsonAssoc = true;
|
|
|
|
|
|
/**
|
|
* 搜索器:试题题目标题
|
|
* @param $value
|
|
* @param $data
|
|
*/
|
|
public function searchTitleAttr($query, $value, $data)
|
|
{
|
|
if ($value) {
|
|
$query->where("title", $value);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 搜索器:试题题型
|
|
* @param $value
|
|
* @param $data
|
|
*/
|
|
public function searchQuestionTypeAttr($query, $value, $data)
|
|
{
|
|
if ($value) {
|
|
$query->where("question_type", $value);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 搜索器:试题创建时间
|
|
* @param $value
|
|
* @param $data
|
|
*/
|
|
public function searchCreatedAtAttr($query, $value, $data)
|
|
{
|
|
$start = empty($value[0]) ? 0 : strtotime($value[0]);
|
|
$end = empty($value[1]) ? 0 : strtotime($value[1]);
|
|
if ($start > 0 && $end > 0) {
|
|
$query->where([["created_at", "between", [$start, $end]]]);
|
|
} else if ($start > 0 && $end == 0) {
|
|
$query->where([["created_at", ">=", $start]]);
|
|
} else if ($start == 0 && $end > 0) {
|
|
$query->where([["created_at", "<=", $end]]);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|