【发布时间】:2015-05-31 17:17:50
【问题描述】:
我收到此错误,htmlentities() 期望参数 1 是字符串,给定对象。如何解决?
我的控制器
public function category()
{
$recordsByCategories=\DB::table('products')
->select('categories', \DB::raw('count(*) as total'))
->groupBy('categories')
->get();
//dd($recordsByCategories);
return view('dashboard.show',compact('recordsByCategories'));
}
我的看法
@foreach($recordsByCategories as $recordsByCategory)
{!!$recordsByCategory->$categories!!}
@endforeach
【问题讨论】:
-
你能把dd的输出贴出来吗——get()返回的数据结构不是字符串数组。