Dealing with Eager loading and the N + 1 problem in Laravel
Every powerful tool must be used wisely. Relationships in Eloquent are no exception to the rule. Actually, one of the most common problems in using Eloquent is the N + 1 problem. To explain it, I will use an example as usual.
Let’s suppose that I am showing some data for the first 100 books. Starting with this data, I also want to print the author name for every single book.
Link:
This post is submitted by our members. Submit a new post.
Tags: Tutorials Laravel 5 Laravel 5.1