In this video, learn how to update a record in the database using the Laravel Eloquent system. Along the way, save new related data records in the database.
- [Instructor] At this point we've created the relationships … and we've used them to get data back. … But what about actually saving the relationship. … We'll work again in our booking controller. … In app, http, controllers, booking controller.php. … We'll go into our store method on line 44. … And here in the store method we'll update … our bookings, users, records, to be label to save … without having to use our DB table column. … We'll erase lines 47 through 50, … and here we'll replace it with booking arrow users, … so we're talking to our relationship, … and then we run the command attach. … And then we pass in request arrow input … user underscore id. … This is how we add a new relationship. … We take our created booking record, … we get the relationship that we want to add. … In this case, our user's relationship. … And then we attach it … by passing in the ID of the related table we'll join on. … What if we wanted to say, save a new record. … Like say we're creating a new user …
- 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.