Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,520 --> 00:00:08,140
Guys, welcome to the course of Lavallade to Capitol Hill, this is part of a 12 and satisfied you will
2
00:00:08,140 --> 00:00:10,040
create a great API.
3
00:00:10,540 --> 00:00:11,770
So if I back to slide.
4
00:00:13,580 --> 00:00:19,850
In the last video, we had done the migration call employees and for the table, we will have the column
5
00:00:19,850 --> 00:00:28,400
call it neme email, phone number, gender and age nine, said this video will create an EPA.
6
00:00:28,520 --> 00:00:34,260
By the help of that, we will create quality will add employees inside DBL.
7
00:00:34,850 --> 00:00:40,130
So if I go back to Ed, so this is the drought will use to create employ.
8
00:00:40,130 --> 00:00:47,960
Got our tiphanie employee now while calling this out while calling this EPA, we to pass some variables
9
00:00:48,140 --> 00:00:55,430
only see somebody barometer's by the help of that we will create or destroy employ inside the bill.
10
00:00:56,270 --> 00:01:02,590
So we will get all the values from Body Parramatta's by the help of request for instance.
11
00:01:03,140 --> 00:01:09,890
So here inside this blog, because this is the method to create our employee, not inside this employ
12
00:01:09,890 --> 00:01:10,460
method.
13
00:01:10,460 --> 00:01:19,700
First of all, the first step we have to do validation macsween to create data and finally send response.
14
00:01:21,530 --> 00:01:29,420
So the fourth estate, that is validation, that request we will use validated method and inside this
15
00:01:29,420 --> 00:01:33,410
validated method will pass an any and the parameters we want.
16
00:01:33,410 --> 00:01:36,260
That is something we email.
17
00:01:36,860 --> 00:01:47,870
Next, we have called for no gender and age means all the needed parameters, means all these parameters
18
00:01:48,050 --> 00:01:49,190
are required.
19
00:01:49,760 --> 00:01:56,810
So we need to pass our validation rule so that the new field should be required.
20
00:01:59,540 --> 00:02:06,980
If I copied the email filles would be required, phone numbers would be required, gender and age apart
21
00:02:06,980 --> 00:02:08,260
from this required rule.
22
00:02:08,600 --> 00:02:15,170
Also, we have the rule for email validation like what we have passed a value for this email address
23
00:02:15,380 --> 00:02:17,540
is valid, email or not.
24
00:02:18,020 --> 00:02:22,240
Also, we have the rule for maximum length and minimum land.
25
00:02:22,710 --> 00:02:28,250
Also, we have the rule for Intisar value or means to find that the value we have passed inside the
26
00:02:28,370 --> 00:02:31,920
it is an integer or a string value.
27
00:02:32,600 --> 00:02:35,840
So we are not going to discuss about all these validation rules.
28
00:02:36,200 --> 00:02:41,600
We are taking all the required for validation rule for all these field inputs.
29
00:02:42,650 --> 00:02:46,310
So this is what we have implemented all about validation.
30
00:02:47,150 --> 00:02:52,790
Now, next, after validation, we do create data and save into a database.
31
00:02:53,270 --> 00:02:57,470
And one more thing for this email, we will use two more rules.
32
00:02:57,470 --> 00:02:59,710
One for the valid email called email.
33
00:03:00,410 --> 00:03:06,050
This property, this validation rule is going to check that the value we have passed is valid, email
34
00:03:06,050 --> 00:03:06,670
or not.
35
00:03:07,370 --> 00:03:16,070
And the third that is unique, it means we are using employee stable and we want that email address
36
00:03:16,190 --> 00:03:21,860
we should enter for the first employee is not repeat sued for the second employee.
37
00:03:22,280 --> 00:03:26,790
So that email address should be unique throughout inside this employee's table.
38
00:03:27,410 --> 00:03:28,460
So these are the rules.
39
00:03:28,460 --> 00:03:31,860
We have applied for this email field here.
40
00:03:32,180 --> 00:03:37,700
So first of all, we need to load our models to, let's say, use employee model.
41
00:03:40,340 --> 00:03:42,800
So we have downloaded our employee model.
42
00:03:43,250 --> 00:03:50,570
So by the help of employee model, we have two options to create and save data inside, be stable.
43
00:03:51,680 --> 00:03:57,230
The first is all about our save method and the second we have called to mattered.
44
00:03:57,620 --> 00:03:59,720
So we will use save method.
45
00:04:00,680 --> 00:04:01,370
Go here.
46
00:04:01,670 --> 00:04:03,620
First of all, let's create an instance.
47
00:04:04,430 --> 00:04:09,400
So employee knew and this is all about employee model.
48
00:04:10,490 --> 00:04:13,020
Now next we to assign values.
49
00:04:13,020 --> 00:04:20,180
So employee, we have the name column and we will get the name value from the request is something request
50
00:04:20,180 --> 00:04:21,680
name again.
51
00:04:21,680 --> 00:04:27,740
If I copy paste a few times knoxfield we have for the email address.
52
00:04:27,740 --> 00:04:34,170
So if I copy this is the table column name and this is the requested parameter.
53
00:04:35,510 --> 00:04:39,140
Next we have phone numbers or copy pasting you too.
54
00:04:39,560 --> 00:04:46,160
Next we have Gentil so this is the name of the column and the gender value we will get inside this.
55
00:04:47,830 --> 00:04:55,660
Gender and finally, we have the Ege, so copy and paste successfully now we have created an instance,
56
00:04:56,050 --> 00:05:07,030
assigned all the values, and finally we will use the same methods as employ and save method if suppose
57
00:05:07,030 --> 00:05:09,310
if we are talking all about the cute method.
58
00:05:09,550 --> 00:05:13,600
So inside that syntax, what we will do employed.
59
00:05:13,600 --> 00:05:14,650
This is our model.
60
00:05:15,040 --> 00:05:23,740
We will use the cricket method and inside this cricket method, passing an array and inside is a simple
61
00:05:23,740 --> 00:05:29,590
way to write our column name and a value like request and name.
62
00:05:30,010 --> 00:05:33,070
We repeat this astep for all the columns.
63
00:05:33,340 --> 00:05:35,240
So this is the another alternative.
64
00:05:36,370 --> 00:05:40,780
But for this video, for this epic view, to use the save method.
65
00:05:40,790 --> 00:05:42,220
So I'm not going to use that.
66
00:05:42,220 --> 00:05:43,030
Remove that.
67
00:05:43,660 --> 00:05:47,910
So here we have the first step implemented call validation and create data.
68
00:05:48,220 --> 00:05:58,390
And finally creating employee with written response solitaries return response rate return the response
69
00:05:58,630 --> 00:06:00,100
in decent format.
70
00:06:01,120 --> 00:06:12,680
Litsa status equals Tufan and message let's employ created successfully.
71
00:06:13,630 --> 00:06:15,970
So save this change now successfully.
72
00:06:15,970 --> 00:06:19,810
We have created our first API that is create API.
73
00:06:20,620 --> 00:06:24,100
So to test this Epper backed Faustman.
74
00:06:25,600 --> 00:06:28,650
If I back to update this, they're out.
75
00:06:28,660 --> 00:06:36,460
So if I copy free to start devlopment server solicit PSP addition serve.
76
00:06:43,420 --> 00:06:51,410
If I copy this, you are also simply I will copy, go to Postman pasting it here.
77
00:06:51,430 --> 00:06:59,200
This is our localhost request type should be post Hadass we need to pass Hewlett's the content type.
78
00:07:01,190 --> 00:07:12,020
Application, Jason, also be warned to accept application and use and so these are the two things like
79
00:07:12,020 --> 00:07:17,960
content type and accept via passing inside this header, go to body, select roll.
80
00:07:18,290 --> 00:07:24,790
And inside this now inside this body will pass our parameters into this Jaeson OPSEC.
81
00:07:25,130 --> 00:07:27,080
So we need name filled.
82
00:07:28,370 --> 00:07:30,470
We need or email value.
83
00:07:31,190 --> 00:07:38,480
We need a phone number and the two columns also we need for the gender and age.
84
00:07:39,140 --> 00:07:43,280
Now inside all these fields, Litsa, the value we are passing.
85
00:07:43,290 --> 00:07:46,820
This is our first employee here.
86
00:07:46,820 --> 00:07:53,870
We have the email address of that employee phone number is something that we value.
87
00:07:53,870 --> 00:07:56,840
I am taking here next.
88
00:07:56,840 --> 00:08:00,650
We have the gender and age.
89
00:08:01,640 --> 00:08:04,100
So let's say that 30 is the age.
90
00:08:04,610 --> 00:08:07,550
So this is what we are passing inside this roll.
91
00:08:08,150 --> 00:08:09,560
And inside is Hadass.
92
00:08:09,560 --> 00:08:12,800
We have selected content type and acceptor.
93
00:08:12,800 --> 00:08:18,080
To add one more thing, we need to add the Routier because this is only for the localhost right now.
94
00:08:18,830 --> 00:08:27,810
Sugo here inside this Epidaurus, BHP simply I will copy Gourriel as we are using the road from epitope
95
00:08:27,810 --> 00:08:32,770
BHP files epis would be prefix and after that this is the road.
96
00:08:33,170 --> 00:08:42,620
So if I copy back to slide, the other lluvia using to create the data is something, something like
97
00:08:42,620 --> 00:08:44,840
this and the parameters.
98
00:08:45,380 --> 00:08:52,240
What we have passed here go to body if I copy back to slide and pasting it here.
99
00:08:53,030 --> 00:08:55,460
So this is all about a decent offset.
100
00:08:55,460 --> 00:09:01,280
What we are passing back to Postman click on send button.
101
00:09:04,360 --> 00:09:09,570
And here we have some added that is called Gwilym, not phone, that is unknown, call them updated
102
00:09:09,580 --> 00:09:16,000
at and this is because actually we have removed the timestamp calls from the stable.
103
00:09:16,330 --> 00:09:21,780
But actually, we didn't call our model that we are not using time is down values.
104
00:09:22,390 --> 00:09:23,800
So this is our mistake.
105
00:09:24,250 --> 00:09:33,130
So to correct that, what we have to do is go inside app models employed because inside this stable
106
00:09:33,130 --> 00:09:35,080
we are not using timewasting values.
107
00:09:35,200 --> 00:09:40,280
And by default, LOEL model will look for all those columns as well.
108
00:09:40,780 --> 00:09:44,650
So we need to tell Hillsville it's a public we are not using.
109
00:09:44,650 --> 00:09:51,040
The timestamps or timestamps equals to fores all we have done.
110
00:09:51,790 --> 00:10:02,170
If we again go back to the first click on Broz right now this noro inserted back to postman click on
111
00:10:02,170 --> 00:10:07,240
send button key and as we can see that employee created successfully.
112
00:10:07,810 --> 00:10:14,950
If I back to Krauser click on Browse and as you can see that our first rule now successfully inserted
113
00:10:15,160 --> 00:10:17,530
by the help of create API.
114
00:10:18,040 --> 00:10:18,850
One more thing.
115
00:10:19,180 --> 00:10:25,570
If I copy this e-mail address a keen and will try to do one more entry with the same email address,
116
00:10:26,080 --> 00:10:27,340
click on Send Button.
117
00:10:27,670 --> 00:10:32,630
As we can see that we are getting out of that is the email had already been taken.
118
00:10:33,330 --> 00:10:40,980
I suppose, instead of all these values, if we pass the null value, click on send button.
119
00:10:41,650 --> 00:10:44,920
This is all about the handling by our validation.
120
00:10:45,100 --> 00:10:51,760
What we have added inside these errors, the new feel is required, email filters required and a phone
121
00:10:51,760 --> 00:10:53,170
number of is required.
122
00:10:54,490 --> 00:10:59,560
So successfully, guys, we had done the API, we had implemented validation.
123
00:10:59,920 --> 00:11:03,420
We have done data as well as sending response.
124
00:11:03,790 --> 00:11:08,500
Now the next video we will see all about the concept of list employees.
125
00:11:08,980 --> 00:11:12,300
So far this radio gas and overwatching and have agreed to.
12643
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.