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(['subject_id']);
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();
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire