Kohone
8/30/2019 - 9:03 AM

get only ids on relations

public function countries()
{
    return $this->belongsToMany("App\Models\Country", 'team_user_countries', 'team_user_id', 'country_id')->orderBy('countries.name');
}

public function allCountriesIds()
{
    return $this->countries()->get()->pluck('id');
}