我想在foreach循环中的同一视图上显示两个变量数据
var seen = {};
newArray = array.filter(function(obj) {
if (seen[obj.field]) {
if (seen[obj.field].includes(obj.environmentLabel) {
return false;
} else {
seen[obj.field].push(obj.environmentLabel);
}
} else {
seen[obj.field] = [obj.environmentLabel];
}
return true;
});
那么如何在laravel刀片模板上显示数据
public function getWalletList()
{
$data = Data::orderBy('id','desc')->get()->toArray();
$user_ids = array_column($data, 'id');
$user_data = User::whereIn('id',$user_ids)->get()->toArray();
$d= array('data'=>$data,'user'=>$user_data);
return view('wallet_list', compact('d'));
}
答案 0 :(得分:0)
为什么不使用两个foreach?
@foreach($d as $value)
<tr>
<td>{{$value['wallet']['name']}}</td>
<td>{{$value->user_id}}</td>
<td>{{$value->price}}</td>
<td>{{$value->price}}</td>
<td>{{$value->updated_at}}</td>
</tr>
@endforeach
@foreach($b as $value)
<tr>
<td>{{$value['wallet']['name']}}</td>
<td>{{$value->user_id}}</td>
<td>{{$value->price}}</td>
<td>{{$value->price}}</td>
<td>{{$value->updated_at}}</td>
<tr>
@endforeach