|
@@ -15,13 +15,20 @@ class CommentTransformer extends TransformerAbstract
|
|
|
{
|
|
|
public function transform(PostComment $postComment)
|
|
|
{
|
|
|
+ if($postComment['is_delete']){
|
|
|
+ $content = '该评论已被删除';
|
|
|
+ }elseif($postComment['parent_id']){
|
|
|
+ $content = '回复 @'.subtext($postComment['reply_username'], 6).': '.$postComment['content'];
|
|
|
+ }else{
|
|
|
+ $content = $postComment['content'];
|
|
|
+ }
|
|
|
return [
|
|
|
'id' => $postComment['id'],
|
|
|
'parent_id' => $postComment['parent_id'],
|
|
|
'uid' => $postComment['uid'],
|
|
|
'username' => $postComment['username'],
|
|
|
'avatar' => $postComment['avatar'],
|
|
|
- 'content' => $postComment['is_delete'] == 1 ? '该评论已被删除' : $postComment['content'],
|
|
|
+ 'content' => $content,
|
|
|
'created_at' => Carbon::parse($postComment['created_at'])->toDateTimeString(),
|
|
|
'is_delete' => $postComment['is_delete'],
|
|
|
];
|