在我的 Controller 中我有
$all = \App\Product::where('campaign_id', $product->campaign_id)->get();
当我在模板中 DD 时
{{ dd($all)}}
我得到一个集合对象
Collection {#340 ▼
#items: array:1 [▼
0 => Product {#341 ▼
#connection: "mysql"
#table: null
#primaryKey: "id"
#keyType: "int"
+incrementing: true
#with: []
#withCount: []
#perPage: 15
+exists: true
+wasRecentlyCreated: false
#attributes: array:10 [▶]
#original: array:10 [▶]
#casts: []
#dates: []
#dateFormat: null
#appends: []
#events: []
#observables: []
#relations: []
#touches: []
+timestamps: true
#hidden: []
#visible: []
#fillable: []
#guarded: array:1 [▶]
}
]
}
如何查看返回的基本数组?
最佳答案
我知道这个问题很老,但不敢相信没有答案。
需要将eloquent模型转成数组,才能展示
{{ dd($all->toArray()) }}
关于arrays - 在 Laravel 中打印出集合的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45099613/