I am trying to get data from pivot table(I have a third column). but it returns empty array. When I do dd() I get this
Collection {#323 ▼
#items: []
}
$a = new Subject();
$authorized_users = $a->users()->get(['auth_teacher']);
models
Subject
public function users()
{
return $this->belongsToMany('App\User')->withPivot('auth_teacher')->withTimestamps();
}
User
public function subjects()
{
return $this->belongsToMany('App\Subject')->withPivot('auth_teacher')->withTimestamps();
}
EDIT: Wrongly written column name. I change it to correctly but the string is still empty
subject_idfrom aSubjectmodel, can you please elaborate your question properly!