1
00:00:00,180 --> 00:00:00,540
OK.

2
00:00:00,930 --> 00:00:09,690
And once we've got get all reviews and get single review in place next, I want to work on these two

3
00:00:09,690 --> 00:00:18,090
bad boys and on a purpose, I'm going to start with the lead review because most of the functionality

4
00:00:18,090 --> 00:00:21,510
will be able to use it in update review.

5
00:00:22,230 --> 00:00:28,560
And this is going to be the first route where I'm going to trust you to use check permissions.

6
00:00:29,100 --> 00:00:31,530
So that's not something we used in a previous project.

7
00:00:31,560 --> 00:00:37,230
Therefore, I showed you the first time how to use it, how to use check permissions.

8
00:00:37,690 --> 00:00:40,830
And this is the point where I want you to use it yourself.

9
00:00:41,400 --> 00:00:48,270
And essentially, when it comes to your deleting a review, we want to get the ID from params like we

10
00:00:48,270 --> 00:00:52,230
just did with a single one that we want to check whether reviews exists.

11
00:00:52,380 --> 00:00:53,100
It doesn't exist.

12
00:00:53,100 --> 00:00:54,510
We go to four or four.

13
00:00:55,770 --> 00:01:00,810
I want to make sure that the review actually belongs to the user.

14
00:01:01,140 --> 00:01:07,830
So even though there is authentication, I also want to make sure that the user I.D. matches are reviewed,

15
00:01:07,830 --> 00:01:10,830
that user and here I'm giving you a hint.

16
00:01:10,980 --> 00:01:13,530
What do we need to pass in to check permissions?

17
00:01:14,040 --> 00:01:18,450
And then if everything is correct, we'll use review doctrine.

18
00:01:18,690 --> 00:01:21,780
And again, this will make sense a little bit later.

19
00:01:22,110 --> 00:01:26,220
Once I show you extra functionality, we haven't talked about it yet.

20
00:01:26,550 --> 00:01:34,080
Once I show you a couple of goodies that will make our project more dynamic, and if everything is correct,

21
00:01:34,350 --> 00:01:36,420
we send back to us.

22
00:01:37,050 --> 00:01:40,410
So let's go to you or your controller.

23
00:01:41,330 --> 00:01:42,470
Let's keep scrolling down.

24
00:01:42,770 --> 00:01:45,040
We have delete our view.

25
00:01:46,160 --> 00:01:50,420
I got just to speed this up because I don't want this video to be 15 minutes long.

26
00:01:50,990 --> 00:01:58,910
Why do we need to do well and get single review for much of all the functionality we can look for?

27
00:01:58,910 --> 00:02:01,100
One here doesn't exist, then throw the error.

28
00:02:01,520 --> 00:02:05,120
The only thing that's missing here is check permissions.

29
00:02:05,690 --> 00:02:06,800
So let's scroll down.

30
00:02:07,730 --> 00:02:11,450
And where we have single here pretty much take everything.

31
00:02:12,330 --> 00:02:18,840
You can even take these status codes and all that, then look for later review, copy and paste.

32
00:02:19,020 --> 00:02:20,340
So we're looking for a ID.

33
00:02:20,940 --> 00:02:21,840
We try to find it.

34
00:02:21,840 --> 00:02:24,240
If it doesn't exist, then what do we do?

35
00:02:24,580 --> 00:02:27,900
Well, we throw 404 correct now in this case.

36
00:02:28,170 --> 00:02:36,180
I want to go with check permissions because I want to make sure that the user I.D. matches the date

37
00:02:36,570 --> 00:02:37,920
of the review user.

38
00:02:38,190 --> 00:02:38,640
Correct?

39
00:02:38,820 --> 00:02:39,690
And what do we pass?

40
00:02:39,700 --> 00:02:47,010
And here we go with record user and then we go with review and got user.

41
00:02:47,250 --> 00:02:49,110
So those are the two things we pass in.

42
00:02:49,590 --> 00:02:55,770
If there's some kind of error, then remember when it comes to a check permissions.

43
00:02:56,160 --> 00:02:58,200
We already have the error codes there, correct?

44
00:02:58,680 --> 00:03:04,590
So if I go to check permissions notice, we check whether the roll is I mean, if it is, I mean, then

45
00:03:04,740 --> 00:03:07,140
admin can do whatever he or she wants.

46
00:03:07,680 --> 00:03:11,850
Then we check whether the user already matches the resources they.

47
00:03:12,790 --> 00:03:14,950
And we need to turn this into a strength.

48
00:03:15,580 --> 00:03:17,440
And then lastly, what do we do?

49
00:03:17,680 --> 00:03:21,250
We throw our if none of these are true.

50
00:03:21,550 --> 00:03:27,850
So fact interview controller, we check remissions and then like I said, this will make sense later.

51
00:03:28,090 --> 00:03:28,930
I'll come back.

52
00:03:28,930 --> 00:03:34,420
I'll show you specifically, Hey, this is why we used remote instead of find one and update.

53
00:03:34,420 --> 00:03:42,520
So here we will go with 08 under review and of the methods we're looking for instead of say we go with

54
00:03:42,520 --> 00:03:46,450
remove, we invoke announced that are sending back their view.

55
00:03:46,700 --> 00:03:47,650
There's no point there.

56
00:03:48,040 --> 00:03:51,610
I'll just say message now will be equal to success.

57
00:03:51,610 --> 00:03:52,390
Review Removed.

58
00:03:52,820 --> 00:03:54,370
And now we just need to test it out.

59
00:03:54,670 --> 00:03:57,010
So let's navigate back through the post.

60
00:03:57,010 --> 00:04:00,520
Man, we're looking for delete.

61
00:04:01,390 --> 00:04:05,140
And I know him, Peter, and I know I set it up as Susan.

62
00:04:05,500 --> 00:04:06,440
So let's try it out.

63
00:04:06,460 --> 00:04:11,860
We should get back the error and we do not authorized to access this route.

64
00:04:12,310 --> 00:04:16,089
So why don't we go back to create a review?

65
00:04:16,480 --> 00:04:20,860
I'll leave the review for the same product, and in this case, I'm going to go with five.

66
00:04:21,810 --> 00:04:23,190
And I'll say very.

67
00:04:24,310 --> 00:04:27,250
Good product, very good product.

68
00:04:27,520 --> 00:04:31,510
And when it comes to comment, I'm just going to go with very, very.

69
00:04:32,660 --> 00:04:35,420
Good product now versus a review.

70
00:04:35,630 --> 00:04:41,570
We're leaving us beta correct, so we leave the review and if we take a look at all the reviews.

71
00:04:42,550 --> 00:04:51,760
Now I have two of them, and I'll grab this I.D. and if I go to delete the review, if I pass in, the

72
00:04:51,760 --> 00:04:55,030
correct I.D. should be successful and I am.

73
00:04:55,510 --> 00:05:00,520
And with this in place, we have knocked out the lead reviewers out as well.

