【发布时间】:2020-04-01 12:39:15
【问题描述】:
当我有 get 函数时,我有以下数据正在检索:
{"id":2,"ticketnaam":"testticket2","ticketprijs":"6000","created_at":"2020-03-27
12:50:24","updated_at":"2020-03-27
12:50:24","pivot":{"user_id":2,"ticket_id":2,"tijd":"09:00:00","beschrijving":"test"}}
我想显示枢轴项目“tijd”和“bechrijving”,但是当我尝试检索它时,它只是没有显示任何错误或其他东西。
我的刀片:
<div class="card-body ">
<table class="table">
<thead>
<tr>
<th scope="col">Strippenkaart</th>
<th scope="col">Tijd</th>
<th scope="col">Beschrijving</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody>
@foreach($details as $detail)
<tr>
<td>
{{$detail->ticketnaam}}
</td>
<td>
{{$detail->tijd}}
</td>
<td>
{{$detail->beschrijving}}
</td>
<td>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
我的用户模型:
public function tickets(){
return $this->belongsToMany('App\Ticket')->withPivot('tijd','beschrijving');
}
【问题讨论】:
-
detail->pivot->tijd和detail->pivot->beschrijving -
欢迎您....