i have two models User and Friend , User has a foreign key in Friend (user_id) since it's a HasMany relation, so i added a function that returns the friendships of the current user
public static function searchFriend(){
return Friend::whereUserId(Auth::id())
->orWhere('friend_id',Auth::id())->get();
}
now i want to search into the current user's friends by firstname so i have to query his friendships and access to the related users through the foreign key user_id or friend_id and query by firstname , how can i apply a query on the returned results by the searchFriend() function
$friends = Friend::searchFriend();