Teacher.php
2.6 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
namespace app\school\model\basic;
use fast\Random;
use think\Model;
use think\Db;
use traits\model\SoftDelete;
class Teacher extends Model
{
use SoftDelete;
// 表名
protected $name = 'teacher';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = 'deletetime';
public static $teacherType = [
0 => '无',
1 => '校园导师',
2 => '企业导师'
];
//学位
const DEGREE = [
0 => '学士',
1 => '硕士',
2 => '博士',
];
//教师职称
const POSITION = [
0 => '助教',
1 => '讲师',
2 => '副教授',
3 => '教授',
4 => '副研究员',
];
const EDUCATION = [
0 => '学前',
1 => '小学',
2 => '初中',
3 => '高中',
4 => '中专',
5 => '大专',
6 => '本科',
7 => '硕士',
8 => '博士',
];
// 追加属性
protected $append = [
'status_text',
'college_text',
'education_text',
'degree_text',
'position_text'
];
//获取教师所属学院
public function getcollegeTextAttr($value,$data){
return Db::name('college')->where(['id' =>$data['college_id']])->value('college_name');
}
public function getdegreeTextAttr($value,$data){
return self::DEGREE[$data['degree']];
}
public function getpositionTextAttr($value,$data){
return self::POSITION[$data['position']];
}
//获取教师学历
public function geteducationTextAttr($value,$data){
$arr = [
0 => '学前',
1 => '小学',
2 => '初中',
3 => '高中',
4 => '中专',
5 => '大专',
6 => '本科',
7 => '硕士',
8 => '博士'
];
return $arr[$data['education']];
}
public function getEducational(){
return self::EDUCATION;
}
public function getStatusList()
{
return ['1' => __('Status 1'), '0' => __('Status 0')];
}
public function getStatusTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
$list = $this->getStatusList();
return isset($list[$value]) ? $list[$value] : '';
}
/* public function getResumeAttr($value, $data){
return !empty($data['resume']) ? json_decode($data['resume'],true):'';
}*/
}