|
@@ -151,14 +151,26 @@ class PostRepository
|
|
|
'post_id' => $request['post_id'],
|
|
|
'parent_id' => 0,
|
|
|
'username' => '暂无',
|
|
|
- 'mobile' => '暂无',
|
|
|
'avatar' => '暂无',
|
|
|
'content' => $request['content'],
|
|
|
+ 'is_delete' => 0,
|
|
|
];
|
|
|
- if(isset($request['parent_id'])){
|
|
|
-
|
|
|
+ if(isset($request['parent_id']) && $request['parent_id'] != 0){
|
|
|
+ $comment = $this->postComment->find($request['parent_id']);
|
|
|
+ if(!$comment){
|
|
|
+ return Response::create([
|
|
|
+ 'message' => '获取评论信息失败',
|
|
|
+ 'status_code' => 500
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ if($comment->parent_id){
|
|
|
+ return Response::create([
|
|
|
+ 'message' => '只能回复评论',
|
|
|
+ 'status_code' => 500
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ $data['parent_id'] = $request['parent_id'];
|
|
|
}
|
|
|
-
|
|
|
DB::beginTransaction();
|
|
|
try{
|
|
|
$this->postComment->create($data);
|
|
@@ -171,7 +183,7 @@ class PostRepository
|
|
|
|
|
|
}catch (QueryException $exception){
|
|
|
DB::rollBack();
|
|
|
- Log::debug('评论内容:'.$request['id'].$exception->getMessage());
|
|
|
+ Log::debug('评论内容:'.$request['post_id'].$exception->getMessage());
|
|
|
return Response::create([
|
|
|
'message' => '评论失败,请重试',
|
|
|
'error' => $exception->getMessage(),
|