In this video, learn how to lazy-load relationship data in Laravel, where after finding records you are able to return the data for the related records.
- [Instructor] Lazy loading relationships in Laravel … is the ability for us to just access a relationship … and the data associated with that relationship, … without specifically calling out loading the data … when we retrieve the record. … We actually saw this earlier, … let's go back to our rooms index view file … at resources, views, rooms, in deck saw blade.php. … Line 19 here is lazy loading … our room type relationship at runtime, … even though in our controller we didn't actually ask for it … to include the room type we just got it for free here. … And we're able to display data based on that relationship. … What about something else? … Let's see a different way … that we can use this lazy loading to effect. … Let's look at the index for the bookings page … at resources, views, bookings, index.blad.php. … On line 27, rather than just showing the room ID … let's actually show the room and the room number. … So we'll replace booking>room ID … with booking>room>number. … What about going a step further? …
- 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.