From the course: Laravel Essential Training
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Add a destroy method to delete a note - Laravel Tutorial
From the course: Laravel Essential Training
Add a destroy method to delete a note
The last major functionality pending in our app is the delete option. Right next to Edit note let's give a button to delete it. Open the show blade view, and right here let's add that button. But this cannot be similar to the link. It needs to be an actual form and have a button. So right here, add a form with action being route('notes.destroy'), and pass the entire note model. And here, once again, the method will be post itself. We will have to... I think I need to close this, yeah... ... the method will be post and we will have to spoof the method using the method blade directive. And here this will be delete. And now let's use the primary button component, x-primary-button. And let's say delete button. Let's add some styles to make it look like a danger button. So this would be bg-red-600. All right. Let's also add the CSRF blade directive. Otherwise, it will not work. Okay. Let's also add a hover class, bg-red-500 or something. Or maybe the background can be 500. And on hover, it…
Contents
-
-
-
-
-
-
-
(Locked)
Add an edit method and view to allow editing of the note4m 30s
-
(Locked)
Add an update method to update edited data2m 25s
-
(Locked)
Add a destroy method to delete a note3m 17s
-
(Locked)
Show flash data to users4m 50s
-
(Locked)
Challenge: Update notes with a new resource1m 14s
-
(Locked)
Solution: Update notes with a new resource7m 44s
-
(Locked)
-
-
-