GoodsComment.php
695 字节
<?php
namespace app\api\model;
use think\Model;
class GoodsComment extends Model
{
protected $append = [
'images_text',
'createtime_text'
];
public function getImagesTextAttr($value,$data)
{
$value = !empty($data['images'])?explode(',',$data['images']):[];
foreach ($value as $key => &$val){
$val = cdnurl($val,true);
}
return $value;
}
public function getCreatetimeTextAttr($value,$data)
{
$value = !empty($data['createtime'])?date('Y-m-d',$data['createtime']):'';
return $value;
}
public function user()
{
return $this->belongsTo('User','user_id','id');
}
}