Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
Guys, welcome to the course of Lavallade to Capitol Hill, this is part of a 12 and satisfied you will
create a great API.
So if I back to slide.
In the last video, we had done the migration call employees and for the table, we will have the column
call it neme email, phone number, gender and age nine, said this video will create an EPA.
By the help of that, we will create quality will add employees inside DBL.
So if I go back to Ed, so this is the drought will use to create employ.
Got our tiphanie employee now while calling this out while calling this EPA, we to pass some variables
only see somebody barometer's by the help of that we will create or destroy employ inside the bill.
So we will get all the values from Body Parramatta's by the help of request for instance.
So here inside this blog, because this is the method to create our employee, not inside this employ
method.
First of all, the first step we have to do validation macsween to create data and finally send response.
So the fourth estate, that is validation, that request we will use validated method and inside this
validated method will pass an any and the parameters we want.
That is something we email.
Next, we have called for no gender and age means all the needed parameters, means all these parameters
are required.
So we need to pass our validation rule so that the new field should be required.
If I copied the email filles would be required, phone numbers would be required, gender and age apart
from this required rule.
Also, we have the rule for email validation like what we have passed a value for this email address
is valid, email or not.
Also, we have the rule for maximum length and minimum land.
Also, we have the rule for Intisar value or means to find that the value we have passed inside the
it is an integer or a string value.
So we are not going to discuss about all these validation rules.
We are taking all the required for validation rule for all these field inputs.
So this is what we have implemented all about validation.
Now, next, after validation, we do create data and save into a database.
And one more thing for this email, we will use two more rules.
One for the valid email called email.
This property, this validation rule is going to check that the value we have passed is valid, email
or not.
And the third that is unique, it means we are using employee stable and we want that email address
we should enter for the first employee is not repeat sued for the second employee.
So that email address should be unique throughout inside this employee's table.
So these are the rules.
We have applied for this email field here.
So first of all, we need to load our models to, let's say, use employee model.
So we have downloaded our employee model.
So by the help of employee model, we have two options to create and save data inside, be stable.
The first is all about our save method and the second we have called to mattered.
So we will use save method.
Go here.
First of all, let's create an instance.
So employee knew and this is all about employee model.
Now next we to assign values.
So employee, we have the name column and we will get the name value from the request is something request
name again.
If I copy paste a few times knoxfield we have for the email address.
So if I copy this is the table column name and this is the requested parameter.
Next we have phone numbers or copy pasting you too.
Next we have Gentil so this is the name of the column and the gender value we will get inside this.
Gender and finally, we have the Ege, so copy and paste successfully now we have created an instance,
assigned all the values, and finally we will use the same methods as employ and save method if suppose
if we are talking all about the cute method.
So inside that syntax, what we will do employed.
This is our model.
We will use the cricket method and inside this cricket method, passing an array and inside is a simple
way to write our column name and a value like request and name.
We repeat this astep for all the columns.
So this is the another alternative.
But for this video, for this epic view, to use the save method.
So I'm not going to use that.
Remove that.
So here we have the first step implemented call validation and create data.
And finally creating employee with written response solitaries return response rate return the response
in decent format.
Litsa status equals Tufan and message let's employ created successfully.
So save this change now successfully.
We have created our first API that is create API.
So to test this Epper backed Faustman.
If I back to update this, they're out.
So if I copy free to start devlopment server solicit PSP addition serve.
If I copy this, you are also simply I will copy, go to Postman pasting it here.
This is our localhost request type should be post Hadass we need to pass Hewlett's the content type.
Application, Jason, also be warned to accept application and use and so these are the two things like
content type and accept via passing inside this header, go to body, select roll.
And inside this now inside this body will pass our parameters into this Jaeson OPSEC.
So we need name filled.
We need or email value.
We need a phone number and the two columns also we need for the gender and age.
Now inside all these fields, Litsa, the value we are passing.
This is our first employee here.
We have the email address of that employee phone number is something that we value.
I am taking here next.
We have the gender and age.
So let's say that 30 is the age.
So this is what we are passing inside this roll.
And inside is Hadass.
We have selected content type and acceptor.
To add one more thing, we need to add the Routier because this is only for the localhost right now.
Sugo here inside this Epidaurus, BHP simply I will copy Gourriel as we are using the road from epitope
BHP files epis would be prefix and after that this is the road.
So if I copy back to slide, the other lluvia using to create the data is something, something like
this and the parameters.
What we have passed here go to body if I copy back to slide and pasting it here.
So this is all about a decent offset.
What we are passing back to Postman click on send button.
And here we have some added that is called Gwilym, not phone, that is unknown, call them updated
at and this is because actually we have removed the timestamp calls from the stable.
But actually, we didn't call our model that we are not using time is down values.
So this is our mistake.
So to correct that, what we have to do is go inside app models employed because inside this stable
we are not using timewasting values.
And by default, LOEL model will look for all those columns as well.
So we need to tell Hillsville it's a public we are not using.
The timestamps or timestamps equals to fores all we have done.
If we again go back to the first click on Broz right now this noro inserted back to postman click on
send button key and as we can see that employee created successfully.
If I back to Krauser click on Browse and as you can see that our first rule now successfully inserted
by the help of create API.
One more thing.
If I copy this e-mail address a keen and will try to do one more entry with the same email address,
click on Send Button.
As we can see that we are getting out of that is the email had already been taken.
I suppose, instead of all these values, if we pass the null value, click on send button.
This is all about the handling by our validation.
What we have added inside these errors, the new feel is required, email filters required and a phone
number of is required.
So successfully, guys, we had done the API, we had implemented validation.
We have done data as well as sending response.
Now the next video we will see all about the concept of list employees.
So far this radio gas and overwatching and have agreed to.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.