Returns a query builder scoped to users.

@return Builder
174407
public function users()
    {
        $wheres = [
            [$this->schema->objectClass(), Operator::$equals, $this->schema->objectClassUser()],
            [$this->schema->objectCategory(), Operator::$equals, $this->schema->objectCategoryPerson()]
        ];

        // OpenLDAP doesn't like specifying the omission of user objectclasses
        // equal to `contact`. We'll make sure we're working with
        // ActiveDirectory before adding this filter.
        if (is_a($this->schema, ActiveDirectory::class)) {
            $wheres[] = [$this->schema->objectClass(), Operator::$doesNotEqual, $this->schema->objectClassContact()];
        }

        return $this->where($wheres);
    }
334016
private function getFollowingQueryBuilder()
    {

        $following = $this->findFollowing(Status::ACCEPTED)->get(['sender_id', 'recipient_id']);
        $recipients  = $following->pluck('recipient_id')->all();
        $senders     = $following->pluck('sender_id')->all();

        return $this->where('id', '!=', $this->getKey())->whereIn('id', array_merge($recipients, $senders));
    }
1293706
public function query()
    {
        $query = app($this->model)->query()->where('resource', $this->resource->getMorphClass());

        return $this->applyScopes($query);
    }
1336900
public function newQueryWithoutScopes()
    {
        $builder = $this->newEloquentBuilder(
            $this->newBaseQueryBuilder()
        );

        // Once we have the query builders, we will set the model instances so the
        // builder can easily access any information it may need from the model
        // while it is constructing and executing various queries against it.
        $builder->setModel($this)->with($this->with);

        $builder->table = $this->getTable();

        return $builder;
    }
1117507
public function query()
    {
        $query = Log::where('description', 'imported')->where('subject_type', $this->resource);

        return $this->applyScopes($query);
    }
566543
private function getQuerySelectQuery(): QueryBuilder
    {
        $query = $this->connection->createQueryBuilder();
        $query->select('DISTINCT q.*, qt.*')
            ->from('ngbm_collection_query', 'q')
            ->innerJoin(
                'q',
                'ngbm_collection_query_translation',
                'qt',
                $query->expr()->andX(
                    $query->expr()->eq('qt.query_id', 'q.id'),
                    $query->expr()->eq('qt.status', 'q.status')
                )
            );

        return $query;
    }
481026
public function getQueryBuilder()
    {
        if (!isset($this->queryBuilder)) {
            $this->queryBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'query');
        }

        return $this->queryBuilder;
    }
301876
public function getQueryBuilder()
    {
        /** @var $queryBuilder QueryBuilder */
        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
            ->getQueryBuilderForTable('tx_gridelements_backend_layout');
        $queryBuilder->getRestrictions()
            ->removeAll()
            ->add(GeneralUtility::makeInstance(DeletedRestriction::class))
            ->add(GeneralUtility::makeInstance(HiddenRestriction::class));
        return $queryBuilder;
    }
352072
protected function query()
	{
		$query = forward_static_call(
			[
				$this->getModelClass(),
				'query',
			]
		);

		$this->modifyQuery($query);

		$eager_loads = $this->getEagerLoads();

		if ( !empty($eager_loads)) {
			$this->safeWith($query, $eager_loads);
		}

		if ( !empty($modifiers = $this->getModifiers())) {
			foreach ($modifiers as $modifier) {
				$modifier($query);
			}
		}

		return $query;
	}
358389
public function scopeOnlyCreatedBy(Builder $query, Model $user)
    {
        return $query->where(config('accountable.column_names.created_by'), $user->getKey());
    }
471134
public function scopeOfCreator(Builder $builder, Model $user): Builder
    {
        return $builder->where('created_by_type', $user->getMorphClass())->where('created_by_id', $user->getKey());
    }
1232140
public function query() : Builder
	{
		if (trim($conditions = $this->conditions) !== '') {
			$this->builder->where('condition', 'LIKE', $conditions);
		}

		return $this->builder;
	}
1013503
public function query()
    {
        $users = Menu::query()
                     ->with('extension')
                     ->where('navigation_id', $this->navigation->id)
                     ->select('menus.*');

        return $this->applyScopes($users);
    }
477971
public function query()
    {
        if (!auth()->guest() && auth()->user()->hasRoles('member')) {
            $this->userId = auth()->user()->id;
        }

        $query = ModuleRow::withoutGlobalScopes()->select(['id', 'name', 'user_id', 'value'])->with('user');

        if (!is_null($this->userId)) {
            $query->where('user_id', $this->userId);
        }
        Event::listen('datatables.order.description', function($query, $direction) {
            $query->orderBy('description', $direction)->orderBy('name', 'desc');
        });
        return $query;
    }
641334
public function queryBuilder()
    {
        if (!$this->queryBuilder) {
            $this->queryBuilder = $this->grid->model()->getQueryBuilder();
        }

        return $this->queryBuilder;
    }
1211070
public function scopePermission(Builder $query, $permissions): Builder
    {
        $permissions = $this->convertToPermissionModels($permissions);

        $rolesWithPermissions = array_unique(array_reduce($permissions, function ($result, $permission) {
            return array_merge($result, $permission->roles->all());
        }, []));

        return $query->where(function ($query) use ($permissions, $rolesWithPermissions) {
            $query->whereHas('permissions', function ($query) use ($permissions) {
                $query->where(function ($query) use ($permissions) {
                    foreach ($permissions as $permission) {
                        $query->orWhere(config('permission.table_names.permissions').'.id', $permission->id);
                    }
                });
            });
            if (count($rolesWithPermissions) > 0) {
                $query->orWhereHas('roles', function ($query) use ($rolesWithPermissions) {
                    $query->where(function ($query) use ($rolesWithPermissions) {
                        foreach ($rolesWithPermissions as $role) {
                            $query->orWhere(config('permission.table_names.roles').'.id', $role->id);
                        }
                    });
                });
            }
        });
    }
853624
public function scopeWithAllTenants(Builder $builder, $tenants): Builder
    {
        $tenants = $this->prepareTenantIds($tenants);

        collect($tenants)->each(function ($tenant) use ($builder) {
            $builder->whereHas('tenants', function (Builder $builder) use ($tenant) {
                return $builder->where('id', $tenant);
            });
        });

        return $builder;
    }