这是查询
$product = Product::with('categories')->take(5)->get();
我无法访问图片上的关系 谢谢你的回答
答案 0 :(得分:0)
// for clarity name this plural as this is a collection too
$products = Product::with('categories')->take(5)->get();
// then in your view:
@foreach ($products as $product)
$product->categories; // accessible like that