1
00:00:00,210 --> 00:00:05,870
In this video, we are going to create a controller to delete a comment.

2
00:00:05,880 --> 00:00:14,340
So let's get into the comment controller, which is this one, and let's locate the dummy controller.

3
00:00:14,340 --> 00:00:19,470
Which is this the step going to be the same as deleting a post?

4
00:00:19,470 --> 00:00:26,070
So let's get into the post and let's copy the logic and here is the logic.

5
00:00:26,340 --> 00:00:35,250
Let's select everything inside the try and let's get into the command and let's look at the delete,

6
00:00:35,250 --> 00:00:39,450
which is this, and I'm going to replace with the one I copied.

7
00:00:39,450 --> 00:00:42,840
So here we are going to find the command.

8
00:00:42,840 --> 00:00:46,440
So I'm going to be the comment module instead of post.

9
00:00:48,660 --> 00:00:51,810
And that and I would change this one to comment.

10
00:00:53,420 --> 00:01:00,650
And next step is we are going to find if the user who is deleting is the owner of the comment going

11
00:01:00,650 --> 00:01:09,920
to be as the comment here as that and the message would be you are not allowed to delete this comment.

12
00:01:11,800 --> 00:01:12,510
Perfect.

13
00:01:12,520 --> 00:01:15,760
And lastly, let's go ahead and then delete.

14
00:01:15,760 --> 00:01:18,280
So I'm going to be the comment model.

15
00:01:23,080 --> 00:01:29,410
And the message would be comment has been deleted successfully.

16
00:01:29,500 --> 00:01:38,380
The next step is let's put this controller behind authentication so routes comment and then here we

17
00:01:38,380 --> 00:01:38,950
go.

18
00:01:39,040 --> 00:01:44,440
Let's look at the delete, which is this, and let me provide the protected.

19
00:01:45,040 --> 00:01:49,780
So it's time to test so inside the tender client.

20
00:01:49,900 --> 00:01:52,150
So let's find all the comments.

21
00:01:52,150 --> 00:01:56,320
So here is a comment and this one is great.

22
00:01:56,320 --> 00:01:58,990
So let's go ahead and delete this one.

23
00:01:58,990 --> 00:02:07,390
So I'll copy the ID of this comment, which is this and this is a delete handler and our paste the ID

24
00:02:07,420 --> 00:02:09,699
here and let's hit send.

25
00:02:10,720 --> 00:02:14,380
And comment has been deleted successfully.

26
00:02:14,740 --> 00:02:15,340
All right.

27
00:02:15,340 --> 00:02:18,790
In this video, let's see how we can update a comment.

