在我的控制器上,通过foreach获取数据,其中$programing->order_id
是相同的,我被dd($notes)
检查,数据显示,但我无法进入我的view PHP。 在尝试$note->get('amount')
方法之前,它也不工作
public function index()
{ $upcomings = Booking_informations::Upcoming();
$notes = [];
foreach ($upcomings as $upcoming) {
$notes[] = Notes :: where('order_id',$upcoming->order_id)-> orderBy('id', 'ASC')->get();
};
return View('upcoming',compact('upcomings','notes',));
}
view.blade.php
<table class="table table-bordered mb-0">
<tbody>
@foreach($notes as $note )
<tr>
<th scope="row">1</th>
<td>{{date('d-M-Y', strtotime($note->created_at))}}</td>
<td>{{$note->details}} </td>
<td>{{$note->amount}} </td>
</tr>
@endforeach
</tbody>
</table>
尝试在foreach循环中引用$note而不是$notes,看看这样做是否有效。
我还注意到您将视图文件命名为view.blade.php。 这应该是upcoming.blade.php以匹配您在返回的视图中提供的名称吗? 只是一个想法。