Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get thumbnail query getting executed multiple time #3

Closed
sumitparkash opened this issue Nov 2, 2017 · 3 comments
Closed

Get thumbnail query getting executed multiple time #3

sumitparkash opened this issue Nov 2, 2017 · 3 comments

Comments

@sumitparkash
Copy link

On the home page if you check in debugger bar you will find that the query to get the post thumbnail is getting executed multiple time . So if you have multiple post with thumbnail , then 2 query get executed per post to get thumbnail.

@sumitparkash
Copy link
Author

As a solution i think you need to change the thumbnail() function under the Post model.

I think you can change the thumbnail() function

return $this->media()->where('id', $this->thumbnail_id)->first();

to this

return $this->media->where('id', $this->thumbnail_id)->first();

and you will find that the multiple query are not getting executed.

@guillaumebriday
Copy link
Owner

guillaumebriday commented Nov 3, 2017

Hey !

Thank you very much for your issue !
You're absolutely right, in this commit (7720099) I added eager loading on the hasThumbnail method but I forgot to change the thumbnail one.

I'm fixing this.

@guillaumebriday
Copy link
Owner

733cc2d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants