I think this should work using Eager Load Contraints.
$users = User::with(array('friend_user' => function($query)
{
$query->where('user_id', '=', '1');
}))->get();
Are you sure you want pivot table for this? It seems that single User can have only one other User that invited him, so basically this is 1-to-many relationship. Then you should have a nullable field on users table: user_id (or inviter_id or whatever u call it). This way you call relations on the same table which is a bit tricky in Eloquent, so leave a note if that would suit you.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community