【发布时间】:2020-02-16 22:39:23
【问题描述】:
我的表 Cous 有一列 date_seance 有 2 条记录。
在我的表Retour 中,我必须检索date_seance。
除此之外,我总是检索相同的值。
23/10/2019 呢?
在我的模型Cous 我有这个:
public function retours()
{
return $this->hasManyThrough(
'App\Retour',
'App\Eleve',
'fk_cours',
'fk_eleve',
'id',
'id'
);
}
在我的Retour index.blade.php 我有这个:
@foreach($retours as $retour)
<tr>
<td> {{$retour->instruction}}</td>
<td> {{$retour->description}}</td>
<td> {{$retour->eleves->nom}}</td>
<td> {{$retour->eleves->prenom}}</td>
<td> {{$retour->eleves()->first()->cours()->first()->date_seance->format('d/m/Y')}}</td>
<td> {{$retour->eleves()->first()->cours()->first()->moniteurs->nom}}</td>
<td> {{$retour->eleves()->first()->cours()->first()->moniteurs->prenom}}</td>
<td> {{$retour->eleves()->first()->paiements()->first()->date_saisie->format('d/m/Y')}}</td>
我的问题是这一行:
<td> {{ $retour->eleves()->first()->cours()->first()->date_seance->format('d/m/Y') }}</td>
我不明白我的问题。
我提前感谢您的帮助。
【问题讨论】:
-
我更新了您的问题并修改了您提到的模型(从:“在我的
Retour模型中我有这个”到:“在我的Cous模型中我有这个”)。如果这不正确,请修改它。
标签: php laravel laravel-5 eloquent relationship