public function create() {
$users = DB::connection('pgsql')->select('select * from test01');
//$data=array();
return view('demo',['data'=>$users]);
}
<div>
@foreach($data as $datas)
<li>{{ $data->id }}</li>
@endforeach
</div>
按照你命名继续错下去应该这么写
<div>
@foreach($data as $datas)
<li>{{ $datas->id }}</li>
@endforeach
</div>
首先 你的foreach循环里代码有问题,@foreach($data as $datas)
<li>{{ $data->id }}</li>
@endforeach