RTippin / messenger-ui

Ready-made UI and web routes for core rtippin/messenger.
MIT License
14 stars 14 forks source link

How to search in all users? And add participants in a group? #6

Closed arifhossen-dev closed 2 years ago

arifhossen-dev commented 2 years ago

1. How can a user search all users (including new fresh users) for conversations?

In the users table

Getting only logged in user

I want to get search results from all new users. Logged in or not.

in user model

Implements

class User extends Authenticatable implements MessengerProvider

Using traite

use Messageable;

Setting method

   public static function getProviderSettings(): array
    {
        return [
            'alias' => 'user',
            'searchable' => true,
            'friendable' => true,
            'devices' => true,
            'default_avatar' => public_path('vendor/messenger/images/users.png'),
            'cant_message_first' => [],
            'cant_search' => [],
            'cant_friend' => [],
        ];
    }

Searchable method

   public static function getProviderSearchableBuilder(
        Builder $query,
        string $search,
        array $searchItems
    ) {
        $query->where(function (Builder $query) use ($searchItems) {
            foreach ($searchItems as $item) {
                $query->orWhere('name', 'LIKE', "%{$item}%");
            }
        })->orWhere('email', '=', $search);
    }

2. How can users add participants in a group without being friends?

I am using BIGINT id in the users table

RTippin commented 2 years ago

Please do not cross-post issues. This issue was handled:

https://github.com/RTippin/messenger/issues/40