laravel-views icon indicating copy to clipboard operation
laravel-views copied to clipboard

Eloquent Eager Loading (with) Supported?

Open nileshd opened this issue 3 years ago • 1 comments

Thanks for the great package.

I am trying to lazy load some of my relationships from the repository method.

public function repository(): Builder
{
    return CheckList::with('Equipment')->where('flag_template',1);
}

While I see the query for the Lazy Loading being run i.e

select * from equipments where id in(1,2,3,4,5)

I also see it's recalling the same queries when I need to display the data from the relationships on the UI for each row..

select * from equipments where id = 1, 
select * from equipments where id = 2 

etc..

Would be great if we can use the relationship data from the Eager loading rather than re-querying the database for them for each row.

nileshd avatar Feb 02 '22 11:02 nileshd

Hi @nileshd sorry for the delay, I'll take a look at it

Gustavinho avatar Feb 14 '22 00:02 Gustavinho