我想从数据透视表中获取数据(我有第三列)。但它返回空数组。当我做DD()我得到这个数据透视表返回空数组
Collection {#323 ▼
#items: []
}
$a = new Subject();
$authorized_users = $a->users()->get(['auth_teacher']);
车型
主题
public function users()
{
return $this->belongsToMany('App\User')->withPivot('auth_teacher')->withTimestamps();
}
用户
public function subjects()
{
return $this->belongsToMany('App\Subject')->withPivot('auth_teacher')->withTimestamps();
}
编辑:错别字列名。我将其更改为正确的,但字符串仍然是空的
我不明白为什么你想从'Subject'模型获取一个'subject_id',可以你请妥善阐述你的问题! –
这里我纠正它(它不subject_id是auth_teacher – OunknownO