[英]laravel how can i show the pivot: data from the get() method
when I have the get function I have the following data whats retrieving:当我有 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"}}
I want to show the pivot items "tijd" and "bechrijving" but when I try to retrieve it it is just showing nothing without any error or something.我想显示枢轴项“tijd”和“bechrijving”,但是当我尝试检索它时,它只是显示任何内容,没有任何错误或其他内容。
my blade:我的刀片:
<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>
my user model:我的用户模型:
public function tickets(){
return $this->belongsToMany('App\Ticket')->withPivot('tijd','beschrijving');
}
I think can be done like that:我认为可以这样做:
{{ $detail->pivot->tijd }}
and和
{{ $detail->pivot->beschrijving }}
Try so!!试试吧!!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.