I have next 'member_companies'
table in DB:
And in model Member has a relation :
public function companies()
{
return $this->belongsToMany(Company::class, 'member_companies');
}
And it return me all companies with dublicates. For example, Member::find(238)->companies->pluck('id')
return
[
6,
5,
7,
2,
10,
8,
4,
13,
14,
10,
8,
13
]
But I want only unique items. Like
[
6,
5,
7,
2,
10,
8,
4,
13,
14,
]
How can I do it with eloquent relations?
branch_id
? – Dissociation