Replies: 2 comments
-
We uses |
Beta Was this translation helpful? Give feedback.
-
Depending on where you load the relationships, I recommend implementing I couldn't find this directly referenced in the documentation right now, but you can see some examples for both pre-defined query methods, as well as dynamic ones at documentaion/resources/authorization. Also keep in mind - if you'll always load relationships, regardless of page 'type', you can define the // Keep in mind - only BelongsTo (and equivalent) relationships are presented on indexes.
// If you need to present a summary of a HasMany relationship, or so, you can load that as well.
public static function indexQuery(NovaRequest $request, $query)
{
return parent::indexQuery($request, $query->with([
'user',
'someBelongsTo',
'otherRelation',
// ...
]));
}
// All relationships can be presented.
public static function detailQuery(NovaRequest $request, $query)
{
return parent::detailQuery($request, $query->with([
'user',
'someHasMany',
'otherRelation',
// ...
]));
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Description:
When a resource defines
fieldsForIndex
thefields
method is still executed for each resource on an index request. When you have a lot of fields and e.g. load relations and so on, this slows down the index request a lot. In our case changing thefields
method like this improves the loading speed quite a bit:I assume this is also the case for other methods like
fieldsForDetail
. I think Nova should only loadfields
if there are no other methods defined for the specific request.Beta Was this translation helpful? Give feedback.
All reactions