我想在1个视图中使用数据2查询,但
错误无法将stdClass类型的对象用作数组
(View:
public function adtranspc(Request $request)
{
$writter = Writter::all();
$processmaster = DB::table('rocessmaster')
->where('pcm_bname', 'LIKE', "%Social%")
->get();
return view('processspj.adtranspc',[
'writter' => $writter,
'processmaster' => $processmaster
]};
*This is my view (this error here)
<table id="table2" class="table table-hover table-striped">
<tr>
<th scope="col"></th>
<th scope="col">Colname1</th>
</tr>
@foreach ($processmaster as $item)
<tr>
<td>{{ $item['pcm_id'] }}</td>
<td>{{ $item['pcm_bname'] }}</td>
</tr>
@endforeach
</table>
答案 0 :(得分:0)
This is my controller
public function adtranspc(Request $request)
{
$writter = Writter::all();
$processmaster = DB::table('rocessmaster')
->where('pcm_bname', 'LIKE', "%Social%")
->get();
return view('processspj.adtranspc',[
'writter' => $writter,
'processmaster' => $processmaster
]};
}
答案 1 :(得分:0)
您正在尝试将object
值打印为array
。您需要以此来更新代码,以这种方式访问对象值
@foreach ($processmaster as $item)
<tr>
<td>{{ $item->pcm_id }}</td>
<td>{{ $item->pcm_bname }}</td>
</tr>
@endforeac