You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are a number of lazy loading issues across the package that start to arise once I have added more than one post, you are calling model relationships within views which is not ideal, it should be called with a YourModel::with('relation')->get() before passing into the view. I know I could turn off lazy loading but that is not ideal for performance.
An example is line 58 of your NinshopsAdmin Controller. looks like this: $posts = BinshopsPostTranslation::orderBy("post_id", "desc")->where('lang_id', $language_id) ->paginate(10);
@Preshiousy1 thanks for your suggestion, yes it causes N+1 query problem. It comes from the translation structure, may be we need a refactor, or going back to the single language to keep the package structure simple, because the current multi lang structure make package structure a little complex.
There are a number of lazy loading issues across the package that start to arise once I have added more than one post, you are calling model relationships within views which is not ideal, it should be called with a YourModel::with('relation')->get() before passing into the view. I know I could turn off lazy loading but that is not ideal for performance.
An example is line 58 of your NinshopsAdmin Controller. looks like this:
$posts = BinshopsPostTranslation::orderBy("post_id", "desc")->where('lang_id', $language_id) ->paginate(10);
should be this:
$posts = BinshopsPostTranslation::with(['post'])->orderBy("post_id", "desc")->where('lang_id', $language_id) ->paginate(10);
as you are calling
$post->post->name
in the view, there are a number of other instances as well.The text was updated successfully, but these errors were encountered: