Mr.*_*. J 1 pivot-table laravel-5
我很困惑如何created_at在我的pivot表中获取列.我有exam_user桌子created_at和updated_at列.现在,我在我看来有这个代码:
@if($exam->users()->where('user_id', Auth::user()->id)->exists())
{{ Auth::user()->assignments()->pivot->created_at }}
<div class="alert alert-success">You have done with this exam.</div>
@else
Run Code Online (Sandbox Code Playgroud)
对此有何看法?
Jag*_*ati 12
设置关系时,需要指定该数据透视表是否具有时间戳.
public function things() {
return $this->belongsToMany('App\Thing')->withTimestamps();
}
Run Code Online (Sandbox Code Playgroud)
编辑:
尝试 Auth::user()->assignments()->first()->pivot->created_at
| 归档时间: |
|
| 查看次数: |
1479 次 |
| 最近记录: |