Social.php
954 字节
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;
class Social extends Base
{
protected $autoWriteTimestamp = true;
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $append = [
'images_arr'
];
public function getCreatetimeAttr($value)
{
return date('Y-m-d',$value);
}
public function getImagesArrAttr($value,$data)
{
$arr = [];
if($data['images']) {
$arr = explode(',',$data['images']);
foreach ($arr as &$v) {
$v = cdnurl($v,true);
}
}
return $arr;
}
public function getTagsAttr($value,$data)
{
$color_arr = [];
if($data['tags']) {
$color_arr = json_decode($data['tags'],true);
}
return $color_arr;
}
public function user()
{
return $this->belongsTo('User','user_id','id')->field('id,nickname,avatar');
}
}