2db47680
hexiaodong
chore: 初始提交 php 遗...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
<?php
namespace addons\exam\model;
use addons\exam\traits\ModelExtend;
use think\Model;
/** 基础模型 */
class BaseModel extends Model
{
use ModelExtend;
protected static function init()
{
parent::init();
self::loadCommonFile();
}
/**
* 加载公共函数库文件
*/
protected static function loadCommonFile()
{
require_once ROOT_PATH . 'addons/exam/helper.php';
}
public function getCreateTimeTextAttr($value, $data)
{
$value = $value ?: ($data['createtime'] ?? '');
return is_numeric($value) ? date('Y-m-d H:i:s', $value) : $value;
}
// +----------------------------------------------------------------------
// 预加载模型关联(仅返回部分数据)
// +----------------------------------------------------------------------
public static function withSimpleUser()
{
return function ($query) {
return $query->field('id,nickname,avatar');
};
}
public static function withSimpleCate()
{
return function ($query) {
return $query->field('id,name');
};
}
public static function withSimplePaper()
{
return function ($query) {
return $query->field('id,title');
};
}
public static function withSimpleRoom()
{
return function ($query) {
return $query->field('id,name');
};
}
}
|