Adldap\Laravel\Commands\Import::getUsers PHP Method

getUsers() public method

Retrieves users to be imported.
public getUsers ( ) : array
return array
    public function getUsers()
    {
        // Retrieve the Adldap instance.
        $adldap = $this->getAdldap($this->option('connection'));
        if (!$adldap->getConnection()->isBound()) {
            // If the connection isn't bound yet, we'll
            // connect to the server manually.
            $adldap->connect();
        }
        // Generate a new user search.
        $search = $adldap->search()->users();
        if ($filter = $this->getFilter()) {
            // If the filter option was given, we'll
            // insert it into our search query.
            $search->rawFilter($filter);
        }
        if ($user = $this->argument('user')) {
            $users = [$search->findOrFail($user)];
        } else {
            // Retrieve all users. We'll paginate our search in case we
            // hit the 1000 record hard limit of active directory.
            $users = $search->paginate()->getResults();
        }
        // We need to filter our results to make sure they are
        // only users. In some cases, Contact models may be
        // returned due the possibility of them
        // existing in the same scope.
        return array_filter($users, function ($user) {
            return $user instanceof User;
        });
    }