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
However this results in Model must be node. thrown InvalidArgumentException …/vendor/kalnoy/nestedset/src/BaseRelation.php40
Reading through #271 I got the impression that this was fixed in #370.
Anyway what I ultimately need is this: $products = Product::with('category.ancestors.posts')->where(..)->get()
And unfortunately I cannot approach this from other end e.g. Category::with('products')->with('ancestors')->with('posts') because Products have to be selected using different criteria than category.
EDIT: Currently I have to do something resource intensive as:
public function getAllPostsAttribute() {
$posts = new Collection();
$posts = $posts->merge($this->posts);
foreach($this->ancestors as $ancestor) {
$posts = $posts->merge($ancestor->posts);
}
return $posts;
}
This then gets called n times (as many unique categories there are in the products set)
The text was updated successfully, but these errors were encountered:
I have products, and posts, that belong to category.
$products = Product::with('category.ancestors')->where('/*some constraints*/')->get()
However this results in
Model must be node.
thrownInvalidArgumentException …/vendor/kalnoy/nestedset/src/BaseRelation.php40
Reading through #271 I got the impression that this was fixed in #370.
Anyway what I ultimately need is this:
$products = Product::with('category.ancestors.posts')->where(..)->get()
And unfortunately I cannot approach this from other end e.g.
Category::with('products')->with('ancestors')->with('posts')
because Products have to be selected using different criteria than category.EDIT: Currently I have to do something resource intensive as:
This then gets called n times (as many unique categories there are in the products set)
The text was updated successfully, but these errors were encountered: