From the course: Laravel Essential Training

Unlock the full course today

Join today to access over 25,100 courses taught by industry experts.

Add an update method to update edited data

Add an update method to update edited data - Laravel Tutorial

From the course: Laravel Essential Training

Add an update method to update edited data

We edited a note in the previous video and tried saving it. Let's verify that we received the edited data first. In the NoteController's update method, let's try and dd the request and see what we get. Go to the browser, refresh, continue. And yes, we have received four parameters with the edited title and edited text. Note that the method blade directive has this input field, which is put. Great. Now once again, similar to inserting a new note, we need to validate the incoming request. So you can copy the same validation rules from here. Paste it here, replace this, paste it. And now this will execute the same way. If our data is valid, then update the note with the new values which will be title, will be $request->title, and then the text will be $request->text. But even before we do this, once again, we need to check if the note model belongs to the logged in user. So copy the same thing here. You can paste it either here or here. Let's paste it there. I'll write the abort if the…

Contents