|
@@ -15,12 +15,25 @@ class LogTransformer extends TransformerAbstract
|
|
{
|
|
{
|
|
public function transform(PostLog $postLog)
|
|
public function transform(PostLog $postLog)
|
|
{
|
|
{
|
|
|
|
+ $type = [
|
|
|
|
+ 'add_pv' => '增加浏览量:',
|
|
|
|
+ 'add_praise_count' => '增加点赞数:',
|
|
|
|
+ 'add_collect_count' => '增加收藏数:',
|
|
|
|
+ 'add_share_count' => '增加分享数:',
|
|
|
|
+ ];
|
|
|
|
+ $data = json_decode($postLog['content']);
|
|
|
|
+ $content = '';
|
|
|
|
+ foreach($data as $key => $val){
|
|
|
|
+ if(!$val) continue;
|
|
|
|
+ $content .= $type[$key] . $val .'、';
|
|
|
|
+ }
|
|
|
|
+ $content = rtrim($content, '、');
|
|
return [
|
|
return [
|
|
'id' => $postLog['id'],
|
|
'id' => $postLog['id'],
|
|
'username' => $postLog['username'],
|
|
'username' => $postLog['username'],
|
|
'log_type' => $postLog['log_type'],
|
|
'log_type' => $postLog['log_type'],
|
|
'created_at' => Carbon::parse($postLog['created_at'])->toDateTimeString(),
|
|
'created_at' => Carbon::parse($postLog['created_at'])->toDateTimeString(),
|
|
- 'content' => $postLog['content'],
|
|
|
|
|
|
+ 'content' => $content,
|
|
];
|
|
];
|
|
}
|
|
}
|
|
}
|
|
}
|