Eager Loading: Lazy Eager Loading

$books = App\Book::all();

if ($someCondition) {
    $books->load('author', 'publisher');
}
$books->load(['author' => function ($query) {
    $query->orderBy('published_date', 'asc');
}]);
Public function format(Book $book)
{
    $book->loadMissing('author');

    return [
        'name' => $book->name,
        'author' => $book->author->name
    ];
}

Eager Loading: Lazy Eager Loading — Structure map

Clickable & Draggable!

Eager Loading: Lazy Eager Loading — Related pages: