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 …
Author
Updated
10/4/2019Released
7/8/2019- Exploring Laravel
- Setting up simple authentication
- Controllers and routes
- Create and index view
- Show, edit, and destroy views
- Models
- Writing scopes in Laravel Eloquent
- Creating one-to-one relationships
Skill Level Beginner
Duration
Views
Related Courses
-
MVC Frameworks for Building PHP Web Applications
with Drew Falkman2h 57m Intermediate -
PHP: Creating Secure Websites
with Kevin Skoglund4h 15m Intermediate -
Ajax with PHP: Add Dynamic Content to Websites
with Kevin Skoglund3h 37m Intermediate -
Learning Symfony 3
with Bernardo Pineda1h 46m Intermediate
-
Introduction
-
What you should know1m 52s
-
1. Installation
-
Install Homestead8m 7s
-
Explore Laravel4m 43s
-
Configuration4m 47s
-
The first page5m 21s
-
-
2. Starting Your Project
-
Simple authentication2m 38s
-
The first migration7m 49s
-
Seeding3m 40s
-
The first route3m 15s
-
The first controller3m 17s
-
The first action5m 1s
-
The first view6m 7s
-
-
3. The Create and Index Views
-
Resource controller routes7m 56s
-
Index action6m 17s
-
Index view6m 6s
-
Create an action4m 55s
-
Create a view3m 49s
-
Store an action5m 22s
-
-
4. The Show, Edit, and Destroy Views
-
Show action and view5m 3s
-
Edit an action5m 47s
-
Edit a view8m 45s
-
Update an action2m 30s
-
Destroy an action5m 15s
-
-
5. Models
-
The first model4m 9s
-
Pagination3m 43s
-
Finding4m 41s
-
Saving4m 37s
-
Editing1m 50s
-
Soft-deleting2m 52s
-
-
6. Eloquent
-
Scopes4m 42s
-
One-to-one relationships4m 32s
-
One-to-many relationships3m 29s
-
Many-to-many relationships4m 44s
-
Lazy-loading relationships3m 16s
-
Eager loading relationships2m 18s
-
Saving relationships3m 54s
-
-
Conclusion
-
Next steps1m
-
- 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.
CancelTake 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.
Share this video
Embed this video
Video: Saving relationships