出於某種原因,我得到一個錯誤:調用未定義的方法生成器僅::()
Call to undefined method Illuminate\Database\Query\Builder::only()
基本上從數據庫中獲取的條目,只使用only()
收集得到具體領域
$canvas = $this->canvasRepo->get(5);
$shapes = $canvas->shapes->each(function($shape) {
return $shape->only('name', 'height', 'width');
});
在循環中,使用'DD($形狀);'檢查對象的信息。並將其附加到您的問題。 –