Your instructor, Justin, teaches you in the ability to delete or destroy records in the database and how to safely provide a link to delete records.
- [Narrator] The last step is … to build the ability … to delete records. … This is also going to be fairly straight forward. … Let's open up our controller again … by going to app, http, controllers, bookingcontoller.php. … Deleting is really straight forward in Laravel. … There's a destroy method. … We'll use this destroy method … to delete the records in our database. … We'll scroll down to line 122 where our destroy method is, … and on line 124 we'll replace the comment with … DB … ::table … parentheses … and in single quotes, … bookings_users … - >where … parentheses, … and in single quotes booking_id, … comma … booking->id … and then we'll call the delete method … to delete this row from the table. … We'll copy this logic … and paste it in for line 125 … to also delete the record for the actual bookings table. … We'll replace the table string with bookings, … and replace the where with the actual id. … Now all we need to do is just redirect back … to our index page with a return redirect() …
- Exploring Laravel
- Setting up simple authentication
- Controllers and routes
- Create and index view
- Show, edit, and destroy views
- Writing scopes in Laravel Eloquent
- Creating one-to-one relationships
Skill Level Beginner
MVC Frameworks for Building PHP Web Applicationswith Drew Falkman2h 57m Intermediate
Ajax with PHP: Add Dynamic Content to Websiteswith Kevin Skoglund3h 37m Intermediate
What you should know1m 52s
2. Starting Your Project
3. The Create and Index Views
4. The Show, Edit, and Destroy Views
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.