multicaret / laravel-acquaintances

This package gives Eloquent models the ability to manage friendships (with groups), followships along with Likes, favorites..etc.
https://laravel-news.com/manage-friendships-likes-and-more-with-the-acquaintances-laravel-package
MIT License
814 stars 72 forks source link

Filter friends #83

Open kife-design opened 2 years ago

kife-design commented 2 years ago

Hello!

First of all, great package.

Is there a way to filter friends? At the moment you have the getFriends() method, but there is no way to say "give me all my friends that are from Belgium" for example.

ange007 commented 2 years ago

Also interested. I don't see an option without editing the source code.

mkwsra commented 2 years ago

Let me check it out

mkwsra commented 2 years ago

Honestly, I'm not gonna work on it now, however, I would really appreciate any help (Send me a PR if you can @ange007)

mkwsra commented 2 years ago

Guys please try this locally, after the PR @ange007 , thankfully, made and let me know so I can create a new version of the library, and then close this issue

86

ange007 commented 2 years ago

Example:

$friends = $user->getFriendsQueryBuilder()
                ->where(function($query) use ($query) {
                    $query->where('name', 'LIKE', "{$query}%")
                        ->orWhere('login', 'LIKE', "{$query}%");
                })
                ->paginate($limit);