1
00:00:00,300 --> 00:00:00,720
Beautiful.

2
00:00:01,050 --> 00:00:04,650
And once we're done with most complex one, the create awe.

3
00:00:05,070 --> 00:00:06,689
Now I want to work on the rest of them.

4
00:00:06,700 --> 00:00:13,290
And since it's our last model, I actually want to combine all of them in one video because at this

5
00:00:13,290 --> 00:00:16,620
point should be very familiar with the functionality.

6
00:00:16,950 --> 00:00:24,960
And I also highly suggest trying to implement this yourself first, because even if you get stuck,

7
00:00:25,170 --> 00:00:28,500
this is going to be a very, very good practice for you.

8
00:00:29,130 --> 00:00:35,360
Now, as far as my suggestions, remember, get all orders is admins only.

9
00:00:35,970 --> 00:00:41,910
So if we take a look, need to double check whether the middleware is there, correct?

10
00:00:42,820 --> 00:00:46,360
So let me go to the root folder for all roots.

11
00:00:46,670 --> 00:00:51,640
And if you follow along with the video, you're sure to have your authorized permission.

12
00:00:52,120 --> 00:00:59,800
But as far as we want all the orders, so that should be very, very straightforward when it comes to

13
00:00:59,800 --> 00:01:05,310
your current user or I'm sorry, I'm skipping one, I had to get single order.

14
00:01:06,070 --> 00:01:12,280
Not only I want to check whether order exists by I.D., I also want to check the permissions.

15
00:01:13,360 --> 00:01:21,160
Then as far as the current user orders, remember that user I.D. is sitting in and record user since

16
00:01:21,160 --> 00:01:28,450
we have middleware from and as far as updating the order, we want to get the order ID from that params.

17
00:01:28,780 --> 00:01:35,890
We want to get payment intent I.D. from that body, then we want to find the order if the order doesn't

18
00:01:35,890 --> 00:01:36,790
exist for a.

19
00:01:37,660 --> 00:01:39,640
We also want to check for more missions.

20
00:01:40,030 --> 00:01:45,730
We only want the user who's associated or the admin to be able to do that.

21
00:01:46,090 --> 00:01:53,740
And then we want to set payment intent I.D. equal to whatever we're getting back from that body and

22
00:01:53,860 --> 00:01:56,320
the order status as paid.

23
00:01:56,650 --> 00:02:03,340
So let's get cracking and we're going to go first or order a controller.

24
00:02:03,580 --> 00:02:07,030
I'll set up all the functionality and then we'll set out in a postman.

25
00:02:07,510 --> 00:02:07,870
Always.

26
00:02:07,870 --> 00:02:09,039
It's too much.

27
00:02:09,729 --> 00:02:12,790
Switching back and forth, get all orders.

28
00:02:13,090 --> 00:02:14,110
What are we want to do here?

29
00:02:14,620 --> 00:02:16,990
Well, we want to use find method.

30
00:02:17,200 --> 00:02:24,900
Correct concert orders is equal to a weight or defined word out fine.

31
00:02:25,090 --> 00:02:27,160
And then we pass an empty object.

32
00:02:27,310 --> 00:02:27,810
That's it.

33
00:02:27,850 --> 00:02:29,250
Now we're getting all the orders.

34
00:02:29,260 --> 00:02:33,310
And again, I know I said this before, but keep in mind, only admins can do that.

35
00:02:33,430 --> 00:02:38,350
So yes, there's very little functionality, but it's only allowed to admin.

36
00:02:38,800 --> 00:02:40,930
And then we'll go with Raz.

37
00:02:41,290 --> 00:02:43,120
And let's add a status here.

38
00:02:44,430 --> 00:02:53,100
As far as the status, set it up, as status codes and OK, if you want to add some more stuff, for

39
00:02:53,100 --> 00:02:55,460
example pagination, you could do so.

40
00:02:55,680 --> 00:03:02,820
Marcus, just looking here for Jason and I want to send back the orders and the account.

41
00:03:02,910 --> 00:03:06,500
So orders and not length.

42
00:03:06,810 --> 00:03:12,690
I was that I want to work on get single order and I'm just going to remove it.

43
00:03:13,140 --> 00:03:18,360
And first, we're looking for I.D., which is going to be incorrect off-ramps, correct.

44
00:03:18,570 --> 00:03:27,180
So ID and I'll give it an alias of Order I.D. that is equal to that params when we want to set up the

45
00:03:27,180 --> 00:03:27,680
order.

46
00:03:27,720 --> 00:03:29,700
So I want to try to get the order.

47
00:03:29,700 --> 00:03:35,670
If it doesn't exist, then it's going to be for a for a manual check for the permissions or consent

48
00:03:36,540 --> 00:03:42,630
order here is equal to a weight order and then find one.

49
00:03:43,640 --> 00:03:45,650
In here or perhaps in the underscore.

50
00:03:46,670 --> 00:03:48,410
And then order it.

51
00:03:49,070 --> 00:03:51,080
If it does not exist, what do we do?

52
00:03:51,120 --> 00:03:59,780
We throw four or four and in order to speed this up, why don't we go here?

53
00:04:00,790 --> 00:04:07,480
And I'm just going to take their statement now again, if you want to recreate it from scratch, that's

54
00:04:07,480 --> 00:04:08,020
up to you.

55
00:04:08,390 --> 00:04:09,910
But I'm just going to take this one here.

56
00:04:10,970 --> 00:04:18,740
And then instead of the product, if there is no order and then I'll say no order with Heidi.

57
00:04:19,700 --> 00:04:22,280
And we're looking for it already.

58
00:04:22,640 --> 00:04:23,030
Correct.

59
00:04:23,450 --> 00:04:27,820
And that in the update, one will also are you this much a naughty one?

60
00:04:27,950 --> 00:04:34,460
We want to go and check permissions and two things we want to pass in the current user, which is right

61
00:04:34,460 --> 00:04:38,240
that user and also the user that is on the order.

62
00:04:38,720 --> 00:04:43,310
So where we go with order and then that user and if there's any kind of issue.

63
00:04:43,730 --> 00:04:46,190
And of course, there's going to be an error.

64
00:04:46,550 --> 00:04:49,190
And lastly, we go or ask that status.

65
00:04:49,460 --> 00:04:51,590
We are looking for status codes.

66
00:04:51,950 --> 00:05:00,120
We'll say, OK, if everything is correct and Jason online, let's send back our order order over here.

67
00:05:00,170 --> 00:05:03,530
Now, get current user orders.

68
00:05:04,250 --> 00:05:05,240
What are the steps?

69
00:05:05,780 --> 00:05:11,540
Well, I want to get all the orders that are associated with what?

70
00:05:12,550 --> 00:05:16,060
With the current user correct, now what is the property?

71
00:05:16,520 --> 00:05:17,470
Various user?

72
00:05:17,890 --> 00:05:19,120
And what's it equal to?

73
00:05:19,420 --> 00:05:22,870
It's equal to record user user I.D..

74
00:05:23,800 --> 00:05:27,480
Let's go to the next one, we get current.

75
00:05:27,670 --> 00:05:28,570
Here's our order.

76
00:05:29,380 --> 00:05:31,600
And let's start by just getting the orders.

77
00:05:32,640 --> 00:05:35,100
Then we'll set it equal to weight.

78
00:05:36,380 --> 00:05:41,450
Ran or got fined, and then let's passing the user.

79
00:05:42,080 --> 00:05:49,550
I mean, it's set it equal to correct that user and then a user I.D. And then in the next line, we're

80
00:05:49,550 --> 00:05:51,080
going to go with the resident status.

81
00:05:52,600 --> 00:05:54,880
I don't pass in the status codes.

82
00:05:55,000 --> 00:05:55,570
OK.

83
00:05:56,440 --> 00:06:05,320
And then Dart and Jason and then set up the Orosz orders count and then orders length orders, board

84
00:06:05,620 --> 00:06:06,550
and length.

85
00:06:07,090 --> 00:06:10,150
And lastly, when it comes to updating the order.

86
00:06:11,310 --> 00:06:18,960
Most of the stuff is going to be exactly the same like we have here for getting the single user or sorry,

87
00:06:19,020 --> 00:06:20,040
single order.

88
00:06:20,340 --> 00:06:23,820
That's what happens if you have 10000 models.

89
00:06:24,000 --> 00:06:24,720
My apologies.

90
00:06:24,720 --> 00:06:25,800
I meant order.

91
00:06:26,280 --> 00:06:30,660
So we take all that functionality where you want to remove the current one.

92
00:06:31,260 --> 00:06:32,850
We're still looking for ORide.

93
00:06:33,810 --> 00:06:34,910
That's true.

94
00:06:34,920 --> 00:06:37,520
But I also want to get the payment ID.

95
00:06:38,070 --> 00:06:46,320
So if everything is correct, if the payment goes through, we'll get back the payment intent I.D. in

96
00:06:46,320 --> 00:06:50,370
the success object and then we'll update our order.

97
00:06:50,730 --> 00:07:00,060
So let's go back seconds and we're looking for payment intent and I.D. again in the post, man obviously

98
00:07:00,060 --> 00:07:05,620
set it up ourselves and we'll still check for the order if it doesn't exist.

99
00:07:05,640 --> 00:07:08,370
We throw our we'll still check for permissions.

100
00:07:08,910 --> 00:07:17,100
We don't want Susan to be updating betas or beta updating Susan's order, and then we want to change

101
00:07:17,100 --> 00:07:24,360
the payment intent I.D. We want to set it equal to her voice and line when it comes to status is going

102
00:07:24,360 --> 00:07:25,260
to be paid.

103
00:07:25,710 --> 00:07:27,030
So I get the order.

104
00:07:27,030 --> 00:07:30,270
I checked the permissions and now I'm going to go with payment intent.

105
00:07:30,270 --> 00:07:33,430
I.D. is equal to payment intent.

106
00:07:34,410 --> 00:07:42,570
And I also want to do the same thing here where I go with order and then that status is equal to and

107
00:07:42,570 --> 00:07:44,340
we'll set it equal to paid.

108
00:07:44,640 --> 00:07:49,180
Lastly, we want to go with a weight or that save.

109
00:07:49,500 --> 00:07:49,890
Correct.

110
00:07:50,310 --> 00:07:51,900
And let's send back the order.

111
00:07:52,840 --> 00:07:58,330
So we are here, Jason and order, so all of that looks correct.

112
00:07:58,660 --> 00:08:02,410
So now let's go back to the postman and let's test that out first.

113
00:08:02,410 --> 00:08:03,280
I want to see.

114
00:08:04,290 --> 00:08:05,370
Who the user.

115
00:08:05,730 --> 00:08:08,430
So let me go here, show current user.

116
00:08:08,820 --> 00:08:09,600
Here is John.

117
00:08:09,900 --> 00:08:11,160
So that is adamant.

118
00:08:11,520 --> 00:08:20,130
So now if I go to your get all orders, if I send, I should be successful, which is just awesome.

119
00:08:20,670 --> 00:08:26,190
So now let's change things around and let's logged in as I don't know, beer.

120
00:08:27,150 --> 00:08:28,990
So here you are.

121
00:08:29,460 --> 00:08:30,420
What's that?

122
00:08:30,990 --> 00:08:32,970
Now I want to create the same order.

123
00:08:33,570 --> 00:08:34,919
So let's create the order.

124
00:08:35,760 --> 00:08:36,809
VIDEO And all that.

125
00:08:37,169 --> 00:08:37,900
That's awesome.

126
00:08:37,919 --> 00:08:42,150
And again, we're looking for this one that's going to be the or are they?

127
00:08:42,510 --> 00:08:49,620
And before we do anything, before we check the single order and also try to access all orders and we

128
00:08:49,620 --> 00:08:52,140
are not successful, which is just great.

129
00:08:52,620 --> 00:08:57,390
Now, as far as the single order, we want to go with orders and we want to send.

130
00:08:58,050 --> 00:08:59,430
Of course, that's not what I wanted.

131
00:08:59,970 --> 00:09:02,970
So here, let me take this idea again.

132
00:09:02,970 --> 00:09:04,200
I'm looking for order.

133
00:09:04,200 --> 00:09:06,840
I'd want to get the single one.

134
00:09:08,280 --> 00:09:09,210
Single one here.

135
00:09:09,310 --> 00:09:10,200
Let's send that.

136
00:09:10,500 --> 00:09:15,420
OK, that looks about right now, I also want to get all my orders.

137
00:09:15,600 --> 00:09:20,520
So let me send year round one where that makes sense.

138
00:09:20,520 --> 00:09:25,810
And then as far as updating the order first, I want to pass in the.

139
00:09:26,400 --> 00:09:31,470
And second, when it comes to body raw Jason.

140
00:09:31,470 --> 00:09:33,180
And then remember what we're looking for.

141
00:09:33,480 --> 00:09:36,330
We're looking for that payment intent.

142
00:09:36,880 --> 00:09:40,230
So here we'll just go with payment.

143
00:09:42,070 --> 00:09:42,340
And.

144
00:09:43,370 --> 00:09:44,210
Intent.

145
00:09:45,180 --> 00:09:49,980
Heidi, and I'm just going to set it to some ground, Heidi.

146
00:09:50,250 --> 00:09:52,150
Say it, let's send.

147
00:09:52,380 --> 00:09:56,130
And since order exists, we have the correct I.D..

148
00:09:56,400 --> 00:10:04,110
And since the owner is better, we're successful and as a result, we're done setting up the or controllers.

