Skip to content

Commit

Permalink
删除回复
Browse files Browse the repository at this point in the history
  • Loading branch information
liyu001989 committed Aug 7, 2020
1 parent a4e903a commit 698bf14
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/Http/Controllers/Api/RepliesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,16 @@ public function store(ReplyRequest $request, Topic $topic, Reply $reply)

return new ReplyResource($reply);
}

public function destroy(Topic $topic, Reply $reply)
{
if ($reply->topic_id != $topic->id) {
abort(404);
}

$this->authorize('destroy', $reply);
$reply->delete();

return response(null, 204);
}
}
3 changes: 3 additions & 0 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
// 发布回复
Route::post('topics/{topic}/replies', 'RepliesController@store')
->name('topics.replies.store');
// 删除回复
Route::delete('topics/{topic}/replies/{reply}', 'RepliesController@destroy')
->name('topics.replies.destroy');
});
});
});

0 comments on commit 698bf14

Please sign in to comment.