spatie / laravel-medialibrary

Associate files with Eloquent models
https://spatie.be/docs/laravel-medialibrary
MIT License
5.78k stars 1.08k forks source link

Laravel nova eager loading model not working #3637

Closed zsoltjanes closed 5 months ago

zsoltjanes commented 5 months ago

Hi Guys! I use Laravel Nova, and as their documentum says i should load the relation with the $with array https://nova.laravel.com/docs/resources/#eager-loading but its not working for me.

The Nova/Media.php file $model is calling your basic modell class.

    public static $with = [
        'model',
    ];

    public static $model = \Spatie\MediaLibrary\MediaCollections\Models\Media::class;

Attempted to lazy load [announcement] on model [App\Models\Application] but lazy loading is disabled.

The Nova/Application model has the $with too:

    public static $with = [
        'user',
        'announcement',
    ];