Php 此集合实例上不存在属性[id][details][details][amount]
在我的控制器上,通过foreach获取数据,其中Php 此集合实例上不存在属性[id][details][details][amount],php,laravel,Php,Laravel,在我的控制器上,通过foreach获取数据,其中$comming->order\u id相同,我通过dd($notes)进行检查。显示数据,但我无法在我的视图php上获取数据。在我尝试$note->get('amount')方法之前,它也不起作用 public function index() { $upcomings = Booking_informations::Upcoming(); $notes = []; foreach ($upcomin
$comming->order\u id
相同,我通过dd($notes)进行检查。
显示数据,但我无法在我的视图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',));
}
即将发布的.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($notes作为$note)
1.
{{date('d-M-Y',strottime($note->created_at))}
{{$note->details}
{{$note->amount}
@endforeach
我已经得到了答案,而下面写的方法有没有更简单的方法来获得结果
<table class="table table-bordered mb-0">
<thead>
<tr>
<th>#</th>
<th>Date</th>
<th>Content</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
@foreach($notes as $note )
@foreach($note as $id )
<tr>
<td scope="row">1</td>
<td>{{$id->details}} </td>
<td>{{$id->amount}} </td>
</tr>
@endforeach
@endforeach
</tbody>
</table>
#
日期
所容纳之物
数量
@foreach($notes作为$note)
@foreach($id注释)
1.
{{$id->details}
{{$id->amount}
@endforeach
@endforeach
尝试在foreach循环中引用$note而不是$notes,然后看看这是否有效
我还注意到您已将视图文件命名为view.blade.php。是否应该使用uncoming.blade.php来匹配您在返回的视图中提供的名称?只是想一想。也不起作用,我将$notes编辑为$note(抱歉,这是拼写错误)是的,它的返回页即将到来。blade.php请修复第二个示例的缩进。谢谢