我尝试从“客户”表中选择两项:
$DF = DemandeFinancement::findOrFail($ndf);
$arr = array('DF'=>$DF);
$client = DB::table('clients')
->join('demande_financements', 'clients.id', '=', 'demande_financements.id')
->select('clients.id', 'clients.name')
->get();
我将在影响数据库的地方返回带有'$ arra'值的视图页面:select
$arra = array('client'=>$client);
return view('DF.detail', $arr, $arra);
答案 0 :(得分:0)
该视图采用一组参数view($view = null, $data = [], $mergeData = []))
因此,如果您要将DF
和client
传递到视图,则两者都需要在同一数组上
return view('DF.detail', ['DF' => $DF, 'client' => $client]);
或者使用compact
return view('DF.detail', compact('DF', 'client');
然后在您的视图中显示(例如)
<p>{{$DF->id}}: {{$client->name}}</p>