I have some belongsToMany relations where I want to return just couple fields using select:
public function followedUsers()
{
return $this->belongsToMany('App\Models\User',null,'followers','followed_users')
->select('_id','slug','profile_name','profile_image');
}
When I query the relation
\App\Models\Users::with('followedUsers)->find($id);
I get an exception ""Invalid argument supplied for foreach()"
If I remove the "select" from the relation it works fine but the models are pretty big so I would send a lot of useless data through the API.
It seems this happens only for belongsToMany, I did not notice this problem for 1 to many relations at least not in 1 the direction
@jenssegers I tested some more relation and noticed the following:
Any update on this?
Most helpful comment
Any update on this?