MatchItems.php
1.2 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
<?php
namespace app\school\model\match;
use app\school\model\basic\User;
use think\Exception;
use think\Model;
use traits\model\SoftDelete;
class MatchItems extends Model
{
use SoftDelete;
// 表名
protected $name = 'match_items';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = 'deletetime';
protected $append = [
'user_text',
'match_title',
'match_type_text'
];
public function remark()
{
return $this->hasMany('app\\school\\model\\review\\ReviewScore','match_items_id','id');//hasMany是一对多
}
public function getuserTextAttr($value,$data)
{
return (new User())->where('id',$data['user_id'])->value('nickname');
}
public function getmatchTitleAttr($value,$data)
{
return (new Match())->where('id',$data['match_id'])->value('match_title');
}
public function getmatchTypeTextAttr($value,$data)
{
return (new MatchType())->where('id',$data['match_type'])->value('name');
}
}