Laravel-medialibrary: N+1 Query on custom view

Created on 1 Nov 2018  路  1Comment  路  Source: spatie/laravel-medialibrary

info: Model: Spatie\MediaLibrary\Models\Media => Relation: model - You should add "with(model)" to eager-load this relation.

Hello,

I am use a custom html rendered for my responsives images.

My code :
```blade

````

I would like to access the media model to be able to display its name in the alt attribute but my code generates a package of sql requests.

How to correct this problem? I wonder if you do not need a pull request to add an eager loader on the Media model.

Cordially.

Most helpful comment

I solved the problem with a ->with('media.model') on the parent model.

I did not know this feature.

>All comments

I solved the problem with a ->with('media.model') on the parent model.

I did not know this feature.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mohammad6006 picture mohammad6006  路  4Comments

mokhosh picture mokhosh  路  3Comments

eichgi picture eichgi  路  3Comments

kickthemooon picture kickthemooon  路  4Comments

amrnn90 picture amrnn90  路  3Comments