I have a merchants table containing a category_id field. And I create the belongsTo relationship.
Now when I visit the /merchant, I found that there is an N+1 query problem when fetching the category info of a merchant:
I created my own controller that extends \TCG\Voyager\Http\Controllers\VoyagerBaseController, and try to lazy load the category data. However, it doesn't work. The N+1 query problem still exists.
Laravel version
9.2
PHP version
8.0.3
Voyager version
1.5
Description of problem
I have a merchants table containing a category_id field. And I create the belongsTo relationship.
Now when I visit the /merchant, I found that there is an N+1 query problem when fetching the category info of a merchant:
I created my own controller that extends \TCG\Voyager\Http\Controllers\VoyagerBaseController, and try to lazy load the category data. However, it doesn't work. The N+1 query problem still exists.
Proposed solution
How can I solve the N+1 query problem?
Alternatives considered
No response
Additional context
No response