src/User/UserRepository.php
public function getIdsForUsername($string, User $actor = null)
    {
        $string = $this->escapeLikeString($string);

        $query = User::where('username', 'like', '%'.$string.'%')
            ->orderByRaw('username = ? desc', [$string])
            ->orderByRaw('username like ? desc', [$string.'%']);

        return $this->scopeVisibleTo($query, $actor)->pluck('id')->all();
    }
public function getIdsForUsername($string, User $actor = null)
    {
        $string = $this->escapeLikeString($string);

        $query = User::where('username', 'like', '%'.$string.'%')
            ->orderByRaw('username = ? desc', [$string])
            ->orderByRaw('username like ? desc', [$string.'%']);

        return $this->scopeVisibleTo($query, $actor)->pluck('id')->all();
    }
public function getIdsForUsername ( $ string , User $ actor = null ) { $ string = $ this -> escapeLikeString ( $ string ) ; $ query = User :: where ( 'username' , 'like' , '%' . $ string . '%' ) -> orderByRaw ( 'username = ? desc' , [ $ string ] ) -> orderByRaw ( 'username like ? desc' , [ $ string . '%' ] ) ; return $ this -> scopeVisibleTo ( $ query , $ actor ) -> pluck ( 'id' ) -> all ( ) ; }
Find users by matching a string of words against their username,
optionally making sure they are visible to a certain user.

@param string $string
@param User|null $actor
@return array
Find users by matching a string of words against their username optionally making sure they are visible to a certain user .