|
@@ -142,26 +142,8 @@ class PostController extends Controller
|
|
}
|
|
}
|
|
$fractal = new Manager();
|
|
$fractal = new Manager();
|
|
$res = new Item($detail, new DetailTransformer($userInfo['uid']));
|
|
$res = new Item($detail, new DetailTransformer($userInfo['uid']));
|
|
- return $array = $fractal->createData($res)->toArray();
|
|
|
|
- $param = $request->all();
|
|
|
|
- $list = $this->postRepositories->suggestPost($param);
|
|
|
|
-
|
|
|
|
|
|
+ $data = $fractal->createData($res)->toArray();
|
|
|
|
|
|
-
|
|
|
|
- $resource = new Collection($list, new SuggestTransformer($userInfo['uid']));
|
|
|
|
- $resource->setPaginator(new IlluminatePaginatorAdapter($list));
|
|
|
|
- $data = $fractal->createData($resource)->toArray();
|
|
|
|
-
|
|
|
|
- if(!(isset($param['current_page']) && $param['current_page'] > 1)){
|
|
|
|
- $newData = [];
|
|
|
|
- foreach($data['data'] as $key => $val){
|
|
|
|
- if($key == 1){
|
|
|
|
- $newData[] = ['show_type' => 1];
|
|
|
|
- }
|
|
|
|
- $newData[] = $val;
|
|
|
|
- }
|
|
|
|
- $data['data'] = $newData;
|
|
|
|
- }
|
|
|
|
return jsonSuccess($data);
|
|
return jsonSuccess($data);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -191,30 +173,18 @@ class PostController extends Controller
|
|
public function replyList(Request $request)
|
|
public function replyList(Request $request)
|
|
{
|
|
{
|
|
$validator = Validator::make($request->all(), [
|
|
$validator = Validator::make($request->all(), [
|
|
- 'id' => 'required|integer',
|
|
|
|
|
|
+ 'id' => 'required|exists:post_comment',
|
|
]);
|
|
]);
|
|
if ($validator->fails()) {
|
|
if ($validator->fails()) {
|
|
return jsonError($validator->errors()->first());
|
|
return jsonError($validator->errors()->first());
|
|
}
|
|
}
|
|
- $detail = $this->postRepositories->commentDetail($request->all());
|
|
|
|
- if(!$detail){
|
|
|
|
- return jsonError('获取评论信息失败');
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
$list = $this->postRepositories->replyList($request->all());
|
|
$list = $this->postRepositories->replyList($request->all());
|
|
$fractal = new Manager();
|
|
$fractal = new Manager();
|
|
$resource = new Collection($list, new ReplyTransformer());
|
|
$resource = new Collection($list, new ReplyTransformer());
|
|
$resource->setPaginator(new IlluminatePaginatorAdapter($list));
|
|
$resource->setPaginator(new IlluminatePaginatorAdapter($list));
|
|
$data = $fractal->createData($resource)->toArray();
|
|
$data = $fractal->createData($resource)->toArray();
|
|
|
|
|
|
- $data['data']['extra'] = [
|
|
|
|
- 'id' => $detail['id'],
|
|
|
|
- 'uid' => $detail['uid'],
|
|
|
|
- 'username' => $detail['username'],
|
|
|
|
- 'reply_count' => $detail->reply->count(),
|
|
|
|
- 'avatar' => $detail['avatar'],
|
|
|
|
- 'content' => $detail['is_delete']?'该评论已被删除':$detail['content'],
|
|
|
|
- 'created_at' => Carbon::parse($detail['created_at'])->diffForHumans(),
|
|
|
|
- ];
|
|
|
|
return jsonSuccess($data);
|
|
return jsonSuccess($data);
|
|
}
|
|
}
|
|
|
|
|