In this video, learn a technique for eager loading relationship data to optimize the performance of your Laravel application.
- One problem with lazy loading relationships, … is it creates a fair bit of overhead … on our database server, … as Laravel will only execute … the query to load in the data when it needs to. … This means they can create the problem … of running multiple sequel crews, … when it could have otherwise optimized the query … by knowing about that query earlier. … For caller changes to load in … the booking room and room type, … each time we loop over and display a record, … Laravel then has to independently query … for the room and the room type. … Instead, we really want Laravel … to be able to ask for all of this data right away. … There's a really easy way to solve this. … Open up the booking controller at app, … acdp, Controllers, BookingController.php. … We'll add in front of the paginate function, … a with, … parentheses, … arrow. … And then inside of the with, … we'll pass in the string room. … This tells Laravel, … hey when you're loading the data for the booking record, … go ahead and load the related data for the room, please. …
- 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.