question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Load relationships on demand

See original GitHub issue

Currently, all relational data is fetched eagerly.

This could potentially be a problem with related data that has vast amount of records. It is probably not always desirable to fetch all relational data of the parent model.

it would be great if we it were possible to somehow define what related data you want to fetch for that particular request.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
phortxcommented, Aug 20, 2018

I could imagine, that the fetch() method accepts a include param with a list of relationships to eager load for that request. Could be useful.

0reactions
phortxcommented, Apr 30, 2019
Read more comments on GitHub >

github_iconTop Results From Across the Web

Laravel Accessor on demand on relationship - Stack Overflow
I've found out how to do this: After getting the entire collection we need to call setAppends() in each model, which contains appends, ......
Read more >
Eloquent: Relationships - The PHP Framework For Web Artisans
Dynamic properties are "lazy loading", meaning they will only load their relationship data when you actually access them. Because of this, developers often...
Read more >
Laravel API Resource: Loading relationship the right way.
We use the with() or loadMissing() function to eager load the relationships. Remember, with() can only be called from Eloquent Query, so it...
Read more >
Loading Related Data - EF Core - Microsoft Learn
Lazy loading means that the related data is transparently loaded from the database when the navigation property is accessed.
Read more >
Laravel Accessor on demand on relationship - Laracasts
Problem: I have accessor in Size.php model which is called in relationship with Item.php Model, in API i need the accessor to work,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found