【发布时间】:2021-10-07 13:40:51
【问题描述】:
我需要在特定的collection 页面中获取brands 数据,但只有多个product。
这是模型之间的关系。
Brand -> HasMany -> Product
Product <= BelongsToMany => Collection
我能够获得所有系列中包含超过 1 种产品的品牌数据,如下所示:
$brands = Brand::has("products")->get(); //this will return all brands that have more than 1 product.
现在我需要在这里添加收藏限制。
我可以从$slug 获取特定页面的收藏。
$collection = Collection::where("slug", $slug)->first();
谁能帮我如何获取特定收藏页面的品牌?
【问题讨论】:
标签: php mysql laravel eloquent laravel-relations