O'Reilly logo
  • GIL EG thinks this is interesting:

$books = \App\Book::with('author')->take(100)->get(); foreach($books as $book) { $author = $book->author; echo $author->first_name . ' ' . $author->last_name; }

From

Cover of Learning Laravel's Eloquent

Note

in this case, the Eager loading decreases the number of queries from 100 to only 2 queries