Код: Выделить всё
#primaryKey: "ID"
#keyType: "int"
+incrementing: true
#with: array:1 [▶]
#withCount: []
+preventsLazyLoading: false
#perPage: 15
+exists: true
+wasRecentlyCreated: false
#escapeWhenCastingToString: false
#attributes: array:23 [▶]
...
#relations: array:1 [▼
"meta" => \MetaCollection {#2861 ▼
#items: array:58 [▼
0 => \PostMeta {#3604 ▼
..
#attributes: array:4 [▼
"meta_id" => 892
"post_id" => 253
"meta_key" => "_manage_stock"
"meta_value" => "yes"
]
...
}
Код: Выделить всё
$metaKey = '_manage_stock';
$filteredProducts = Product::all()
->filter(function ($product) use ($metaKey) {
return $product->meta->contains(function ($meta) use ($metaKey) {
return $meta->meta_key === $metaKey;
});
});
Подробнее здесь: https://stackoverflow.com/questions/794 ... on-the-met