初始化项目:添加后端代码、ThinkPHP框架、前端资源
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model\app\exam;
|
||||
|
||||
use think\Model;
|
||||
|
||||
|
||||
class WarehouseQuestion extends Model
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 表名
|
||||
protected $name = 'app_exam_warehouse_question';
|
||||
|
||||
// 自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = 'integer';
|
||||
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = 'createtime';
|
||||
protected $updateTime = false;
|
||||
protected $deleteTime = false;
|
||||
|
||||
// 追加属性
|
||||
protected $append = [
|
||||
'option',
|
||||
'type_text',
|
||||
];
|
||||
|
||||
|
||||
public function getOptionAttr($value, $data)
|
||||
{
|
||||
if(!isset($data['option']) || !$data['option']){
|
||||
return [];
|
||||
}
|
||||
|
||||
return json_decode($data['option'],true);
|
||||
}
|
||||
|
||||
public function getTypeTextAttr($value, $data)
|
||||
{
|
||||
// $lang = require_once APP_PATH."admin/lang/zh-cn/app/exam/warehouse_question.php";
|
||||
|
||||
if(!isset($data['type']) || !$data['type']){
|
||||
return '';
|
||||
}
|
||||
|
||||
return __('Question Type '.$data['type']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getTypeList()
|
||||
{
|
||||
|
||||
return ['single' => __('Status single'),'multiple' => __('Status multiple'),'judge' => __('Status judge'),'indefinite' => __('Status indefinite'),'fillblank' => __('Status fillblank'),'essay' => __('Status essay')];
|
||||
}
|
||||
|
||||
//难度
|
||||
public function getDegreeList()
|
||||
{
|
||||
return ['1' => __('Degree 1'),'2' => __('Degree 2'),'3' => __('Degree 3')];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function group()
|
||||
{
|
||||
return $this->belongsTo('app\admin\model\app\exam\WarehouseGroup', 'group_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user