Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,510 --> 00:00:07,970
OK, guys, welcome to the course of Lavallade EPRDF material, this is part 15 inside this video.
2
00:00:08,250 --> 00:00:11,640
We're going to create an API for updated information.
3
00:00:12,460 --> 00:00:20,110
If I back to Ed in the last video, step by step, we had done for this pre-heat list and we have done
4
00:00:20,340 --> 00:00:22,070
get single important detail.
5
00:00:22,500 --> 00:00:26,130
Now, this time will work for updated API.
6
00:00:27,270 --> 00:00:31,770
So inside this update API, we need to pass the parameters.
7
00:00:31,770 --> 00:00:38,970
It means updated employee information as well as employee ID on the behalf of this employee ID.
8
00:00:39,240 --> 00:00:45,720
What we are getting inside this ID variable will update the existing data by the help of Body Palmettos.
9
00:00:46,020 --> 00:00:48,930
What we will get via request instance.
10
00:00:49,800 --> 00:00:55,860
So here inside this method block, first of all, we need to check that the employee accessed on the
11
00:00:55,860 --> 00:00:57,620
behalf of this idea or not.
12
00:00:58,140 --> 00:01:11,100
So let's say if employee will use Vehle method, let's ID equals to idee and we will use access to method.
13
00:01:12,450 --> 00:01:20,430
If employee accessed, then we will go inside this if block, otherwise we will go inside this as block.
14
00:01:20,790 --> 00:01:24,390
So in the last video we had handled the same situation.
15
00:01:24,660 --> 00:01:30,840
So I will copy this massive something employee not phone call inside this ls blocked and pasting it
16
00:01:30,840 --> 00:01:31,350
here.
17
00:01:31,770 --> 00:01:34,830
Now inside this safe block it means we have no employee.
18
00:01:35,130 --> 00:01:37,890
So what I will do this employee.
19
00:01:41,360 --> 00:01:51,400
Equals to employ we will use find method and inside this find method, we will pass employee ID here.
20
00:01:51,650 --> 00:01:54,710
What fine method will do, find martyring.
21
00:01:54,710 --> 00:01:59,510
Laravel basically finds the data on the behalf of primary key.
22
00:01:59,990 --> 00:02:04,580
As we can see here, that inside this will matter we have a specified the column.
23
00:02:04,910 --> 00:02:10,940
But inside this find method, we haven't specified that this idea is compared with the idea column.
24
00:02:11,210 --> 00:02:15,830
Automatically, this find method will decide with the primary key.
25
00:02:16,570 --> 00:02:23,240
So after finding details, what I will do, we need to update the existing data.
26
00:02:23,810 --> 00:02:28,900
So here, let's employ we to update our new value.
27
00:02:29,510 --> 00:02:32,540
So let's request name here.
28
00:02:35,180 --> 00:02:41,480
Now, if I copy paste a few more times, the second is Follett's email.
29
00:02:42,620 --> 00:02:45,860
I will copy pasting you to till next.
30
00:02:45,860 --> 00:02:47,970
We have something for the phone number.
31
00:02:48,560 --> 00:02:50,250
Copy paste.
32
00:02:50,720 --> 00:03:00,220
Here we have for the gender will copy and paste and for the last time that we have called each here.
33
00:03:01,400 --> 00:03:03,890
So let's add that and one more thing.
34
00:03:04,190 --> 00:03:08,530
While updating information, we want some form validation as well.
35
00:03:09,350 --> 00:03:13,840
But here we are discussing all about update employed method.
36
00:03:14,060 --> 00:03:21,170
So this time we are not going to implement some type of validation because while updating any information,
37
00:03:21,590 --> 00:03:24,530
this information is either required or not.
38
00:03:24,900 --> 00:03:31,940
Let's add that we have a case when we want to update all information, but also we have the second case
39
00:03:32,150 --> 00:03:39,320
in which we want to update only phone number so we can specify the phone validation like all the files
40
00:03:39,320 --> 00:03:42,940
are required in the case of update employee API.
41
00:03:43,550 --> 00:03:53,600
So instead, what I will do, we need to check that if not empty, it means inside of body parameters.
42
00:03:53,600 --> 00:04:00,710
If the names exist and if it has a value, then in that situation we need to update with updated value.
43
00:04:00,980 --> 00:04:08,270
Otherwise, employee and name, we will update our name filled with the existing value.
44
00:04:09,320 --> 00:04:17,000
What this line means, this line means that if we are passing the name value inside body for update,
45
00:04:17,210 --> 00:04:24,380
let's say for the new value, if the new value exists and it is not empty, then we will update.
46
00:04:24,590 --> 00:04:27,770
Otherwise the existing value will be updated.
47
00:04:28,400 --> 00:04:39,620
So seem really to repeat for all the columns, if I copy and paste, copy and paste, copy and paste
48
00:04:40,400 --> 00:04:43,370
and file a copy and paste, not going to change the keys.
49
00:04:43,670 --> 00:04:45,980
So email, copy and paste.
50
00:04:47,780 --> 00:04:50,720
Next we have for the phone number so I will copy.
51
00:04:55,670 --> 00:04:56,720
For the gentle.
52
00:04:59,780 --> 00:05:01,490
And finally, for The Age.
53
00:05:04,110 --> 00:05:10,650
So after updating information, we to return a response that is yuzu has been updated, so let's return
54
00:05:11,010 --> 00:05:14,260
response, Dewson mattered.
55
00:05:15,610 --> 00:05:21,540
It's a status equals to one message.
56
00:05:24,100 --> 00:05:34,720
Employ updated successfully, I'll save all the U.S. food and also if you want to specify the US to
57
00:05:34,990 --> 00:05:40,270
good, we can do it here, but by default it will return to hundred.
58
00:05:41,110 --> 00:05:47,830
Now, if you go inside this EPA dot, so to call this methode update, employ the syntaxes something
59
00:05:47,830 --> 00:05:54,920
update employee re to use put request type and also need to pass the employee ID into the humoral.
60
00:05:55,480 --> 00:05:56,740
So back to Postman.
61
00:05:57,220 --> 00:05:59,520
First of all, I will copy this syntax.
62
00:06:00,070 --> 00:06:04,300
It means that you are like localhost epis single employers and all.
63
00:06:04,780 --> 00:06:11,040
But inside this case we have updated one employee, so I will copy Cohill.
64
00:06:12,330 --> 00:06:19,750
And let's add that by default, if we want to update 28, I'd put a request.
65
00:06:19,750 --> 00:06:21,600
I had 28 ideas.
66
00:06:21,610 --> 00:06:24,790
We know that this this does not exist in our table.
67
00:06:25,180 --> 00:06:32,140
So when we pressed the button employee not found, but when we passed the two value, as we know that
68
00:06:32,140 --> 00:06:38,950
it excessed analyser that for this second no employee I.D., we want to update this name value.
69
00:06:39,520 --> 00:06:49,870
So he'll go he'll Hadass, we will pass content type equal to application, Jason.
70
00:06:51,900 --> 00:07:03,750
Accept application, Jason, go to body roll and inside these two to pass if we want to update the new
71
00:07:03,750 --> 00:07:08,850
value only Vijay Kumar Singh.
72
00:07:09,960 --> 00:07:15,790
This is the name what we have written as updated value instead of this old value.
73
00:07:17,250 --> 00:07:23,710
Now, when we press the send button status equals to OK, employee update updated successfully.
74
00:07:24,180 --> 00:07:28,320
Now, if you go back to this Epper, which is listing all the employees, click on send button.
75
00:07:29,400 --> 00:07:35,280
And I think that the employee has not been updated if we go back to Ed.
76
00:07:37,170 --> 00:07:45,360
And if you go inside to update employ method, here we are finding the details, updating all the informations
77
00:07:46,330 --> 00:07:52,530
and one more thing, actually, the most important thing we forgot to add using save method.
78
00:07:54,050 --> 00:08:01,730
Because without save mattered, how can we update the information to database so simply employ and save
79
00:08:02,690 --> 00:08:03,940
all we have done?
80
00:08:04,370 --> 00:08:08,800
So if we save all these changes to Postman, go here.
81
00:08:08,810 --> 00:08:15,170
Let's say update employee to now press send button employee updated successfully.
82
00:08:15,170 --> 00:08:21,670
Go to the list of Epis, click on Send Button and as you can see that the name has been updated.
83
00:08:22,520 --> 00:08:23,540
Now one more time.
84
00:08:23,780 --> 00:08:29,490
If we want to update the information of this Tuddenham we employed its name and gender.
85
00:08:29,930 --> 00:08:35,150
So how can we update simply Google Plus employee IDs equals to three?
86
00:08:36,230 --> 00:08:38,540
Litsa, we want to name the date he'll.
87
00:08:40,790 --> 00:08:50,410
This is the name and he'll be want to update the gender, so it's a female.
88
00:08:50,810 --> 00:08:55,310
So on behalf of this third no employee, I'd be updating this information.
89
00:08:55,610 --> 00:08:59,180
Click on send button employee updated successfully.
90
00:08:59,540 --> 00:09:02,620
Goodhue if we click on Send Button.
91
00:09:02,870 --> 00:09:09,770
And as you can see that the name has been updated and the gender has been updated so successfully.
92
00:09:09,780 --> 00:09:12,410
Guys, this is the EPA concept vehicle.
93
00:09:12,650 --> 00:09:18,730
We have implemented update concept and this is we have used put request type.
94
00:09:20,250 --> 00:09:26,850
Here we are finding the employer exists or not, if we exist, we are finding all the details, updating
95
00:09:26,850 --> 00:09:30,730
all the existing values and saving inside our table.
96
00:09:31,530 --> 00:09:39,600
And if employed does not exist, simple, we have to response as employee not found in the next video,
97
00:09:39,880 --> 00:09:46,440
we will work over the last play of this epic Anthoula concept for delete employee so far this session.
98
00:09:46,450 --> 00:09:48,780
Guys, thank you for watching and have a great day.
10418
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.