IdeaComment.php
1.1 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
<?php
namespace app\api\model;
use think\Model;
class IdeaComment extends Model
{
protected $append = [
// 'like_nicknames_text',
'createtime_text',
'images_text'
];
// public function getLikeNicknamesTextAttr($value,$data)
// {
// $value = isset($data['like_nicknames']) ? explode(',',$data['like_nicknames']) : [];
// return $value;
// }
public function getImagesTextAttr($value,$data)
{
$value = isset($data['images']) && !empty($data['images']) ? explode(',',$data['images']) : [];
foreach ($value as $key => $val){
$value[$key] = cdnurl($val,true);
}
return $value;
}
public function getCreatetimeTextAttr($value,$data)
{
$value = isset($data['createtime']) && $data['createtime'] > 1 ? date('Y-m-d',$data['createtime']) : '';
return $value;
}
public function user()
{
return $this->belongsTo('User','user_id','id');
}
public function touser()
{
return $this->belongsTo('ToUser','touser_id','id');
}
}