Finds the first model matching the given filters.

@param \Rhubarb\Stem\Filters\Filter[] $filters
@throws RecordNotFoundException
@return Model|static
971168
public static function findFirst(Filter ...$filters)
    {
        $results = static::find(...$filters);

        if (sizeof($results) == 0) {
            throw new RecordNotFoundException(get_called_class(), 0);
        }

        return $results[0];
    }
371255
public function setWhereAny($filters)
    {
        $filters = func_num_args() > 1 ? func_get_args() : $filters;
        return $this
            ->setWhere(array())
            ->addWhereAny($filters);
    }
1180222
public function addFiltersWithAndToTable(iterable $filters): self
    {
        $addWith = $this->expr()->andX();
        $this->applyFilters($addWith, $this->getTableName(), $filters);
        $addWith->count() <= 0 ?: $this->andWhere($addWith);

        return $this;
    }
638513
public function findOneBy($filters, $inDeleted = false)
    {
        $qb = $this->db->createQueryBuilder();

        $qb->select($this->getSelect($this->profile))
            ->from($this->table, 't')
            ->where('1 = 1');

        $this->addJoins($qb, $this->getJoins($this->profile));
        $params = $this->addFilters($qb, $this->getFilters($this->profile));
        $params = array_merge($params, $this->addFilters($qb, $filters));

        return $this->getRow($qb, $params, $inDeleted);
    }
271810
public function setFilters(array $filters)
    {
        if (empty($this->filters)) {
            $this->filters = $this->getDefaultFilters();
        }

        $this->filters = array_merge(
            $this->filters, $filters
        );

        return $this;
    }
500263
public function withFilters(array $filters = null)
    {
        if ($filters) {
            foreach ($filters as $filter) {
                switch ($filter['type']) {
                    case 'select':
                        $this->select($filter['fields']);
                        break;
                    case 'andWhere':
                        $this->andWhere($filter['field'], $filter['operation'], $filter['value']);
                        break;
                    case 'orWhere':
                        $this->orWhere($filter['field'], $filter['operation'], $filter['value']);
                        break;
                    case 'andHaving':
                        $this->andHaving($filter['field'], $filter['operation'], $filter['value']);
                        break;
                    case 'orHaving':
                        $this->orHaving($filter['field'], $filter['operation'], $filter['value']);
                        break;
                    case 'addGroupBy':
                        $this->addGroupBy($filter['field']);
                        break;
                    case 'addOrderBy':
                        $this->addOrderBy($filter['field'], $filter['order']);
                        break;
                    case 'fkAddOrderBy':
                        $this->fkAddOrderBy($filter['field'], $filter['fkField'], $filter['order']);
                        break;
                    case 'paginate':
                        if (isset($filter['page'])) {
                            $this->paginate($filter['limit'], $filter['page']);
                        } else {
                            $this->paginate($filter['limit']);
                        }
                        break;
                }
            }
        }

        return $this;
    }
716724
public function getRecords($filter = '', $order = ['.id'], $page = 1, $count = null, $dataDimensions = null)
    {
        if ($dataDimensions == null) {
            $dataDimensions = $this->getCurrentDataDimensions();
        }

        if (!is_array($order))
        {
            $order = [$order];
        }

        if ($this->readConnection instanceof FilteringConnection) {
            $records = $this->readConnection->getRecords($this->getCurrentContentTypeName(), $dataDimensions, $filter,
                $page, $count, $order);
        } else {

            $records = $this->getAllRecords($dataDimensions);

            if ($filter != '') {
                $records = RecordsFilter::filterRecords($records, $filter);
            }

            $records = RecordsSorter::orderRecords($records, $order);

            if ($count != null) {
                $records = RecordsPager::sliceRecords($records, $page, $count);
            }
        }

        foreach ($records as $record) {
            $record->setRepository($this);
        }

        return $records;
    }
890138
public function setFilters(array $filters)
    {
        $this->filters = $filters;

        $this->updateInternalState();

        $this->handleChangedParameters();

        return $this;
    }
1196180
public static function where($filter, $value = null)
    {
        if (is_scalar($filter)) {
            /** @var \ManaPHP\ModelInterface $model */
            $model = Di::getDefault()->getShared(static::class);
            return static::query(null, $model)->whereEq($model->getPrimaryKey(), $filter);
        } else {
            return static::query()->where($filter, $value);
        }
    }
858921
public function filter($filters)
    {
        $filtered = [];
        foreach ($this->objectArr as $obj) {
            $success = true;
            foreach ($filters as $prop => $value) {
                if ($obj->$prop !== $value) {
                    $success = false;
                    break;
                }
            }
            if ($success) {
                $filtered[] = $obj;
            }
        }
        return $filtered;
    }
1077708
public function where($filters, $values = null)
    {
        if ($filters === null) {
            return $this;
        }

        foreach (is_array($filters) ? $filters : [$filters => $values] as $filter => $value) {
            if (is_int($filter)) {
                $this->whereExpr($value);
            } elseif (is_array($value)) {
                if (preg_match('#([~@!<>|=%]+)$#', $filter, $match)) {
                    $operator = $match[1];
                    $field = substr($filter, 0, -strlen($operator));
                    if ($operator === '~=') {
                        if (count($value) !== 2) {
                            throw new MisuseException(['`value of :filter` filter is invalid', 'filter' => $filter]);
                        }
                        $this->whereBetween($field, $value[0], $value[1]);
                    } elseif ($operator === '@=') {
                        $this->whereDateBetween($field, $value[0], $value[1]);
                    } elseif ($operator === '|=') {
                        $this->_filters[] = [$field => ['$in' => $value]];
                    } elseif ($operator === '!=' || $operator === '<>') {
                        $this->whereNotIn($field, $value);
                    } elseif ($operator === '=') {
                        $this->whereIn($field, $value);
                    } elseif ($operator === '%=') {
                        $this->whereMod($field, $value[0], $value[1]);
                    } else {
                        throw new MisuseException(['unknown `:operator` operator', 'operator' => $operator]);
                    }
                } elseif (!$value || isset($value[0])) {
                    $this->whereIn($filter, $value);
                } else {
                    $this->_filters[] = [$filter => $value];
                }
            } elseif (preg_match('#^([\w\.]+)\s*([<>=!^$*~,@dm?]*)$#', $filter, $matches) === 1) {
                list(, $field, $operator) = $matches;

                if (strpos($operator, '?') !== false) {
                    $value = is_string($value) ? trim($value) : $value;
                    if ($value === '' || $value === null) {
                        continue;
                    }
                    $operator = substr($operator, 0, -1);
                }

                if ($operator === '') {
                    $operator = '=';
                }

                if (in_array($operator, ['=', '~=', '!=', '<>', '>', '>=', '<', '<='], true)) {
                    $this->whereCmp($field, $operator, $value);
                } elseif ($operator === '^=') {
                    $this->whereStartsWith($field, $value);
                } elseif ($operator === '$=') {
                    $this->whereEndsWith($field, $value);
                } elseif ($operator === '*=') {
                    $this->whereContains($field, $value);
                } elseif ($operator === ',=') {
                    $this->whereInset($field, $value);
                } elseif ($operator === '@d=') {
                    $this->whereDate($field, $value);
                } elseif ($operator === '@m=') {
                    $this->whereMonth($field, $value);
                } else {
                    throw new MisuseException(['unknown `:operator` operator', 'operator' => $operator]);
                }
            } elseif (strpos($filter, ',') !== false && preg_match('#^[\w,\.]+$#', $filter)) {
                $this->where1v1($filter, $value);
            } else {
                throw new InvalidValueException(['unknown mongodb query `filter` filter', 'filter' => $filter]);
            }
        }

        return $this;
    }
1228752
public function filters(Collection $filters)
    {
        foreach ($filters as $element) {
            // do not apply filter if no request var were found.
            if (!app('request')->has($element->id())) {
                continue;
            }

            $this->assemblyQuery($element);
        }

        return $this;
    }
851785
public function setFilters($filters = []) {
		if ($filters) {
			foreach ($filters as $key => $value) {
				$this->setFilter($key, $value);
			}
		}

		return $this;
	}
1094087
public function setFilters($filters = [])
    {
        foreach ($filters as $field => $rules) {
            if ($field === 'fullSearch') {
                $this->addFilter($field, $rules, null);
                continue;
            }

            if (is_a($rules, MultiFullTextFilter::class)) {
                $this->addFilter($field, $rules, null);
                continue;
            }

            foreach ($rules as $operator => $value) {
                if (!in_array($operator, $this->availableFilters) || (empty($value) && $value != '0')) {
                    continue;
                }
                $this->addFilter($field, $value, $operator);
            }
        }

        return $this;
    }
1250090
public function filterAll(array $filters)
    {
        $filterList = [];
        foreach ($filters as $key => $value) {
            $filterList[] = $key . ':' . $value;
        }

        $result = $this->connection()->get($this->getEndpoint(), ['filter' => implode(',', $filterList)], true);

        return $this->collectionFromResult($result);
    }
732004
public function addFilters(array $filters)
    {
        foreach ($filters as $key => $filter) {
            $this->addFilter($filter);

            /** Name the expression if $key is a non-numeric string. */
            if (is_string($key) && !is_numeric($key)) {
                $filter = end($this->filters);
                $filter->setName($key);
            }
        }

        return $this;
    }
414419
public function filters($filters)
    {
        if(!is_array($filters)){
            throw new \RuntimeException('Filters not specified', ResourceException::FILTERS_NOT_SPECIFIED);
        }

        $this->filters = json_encode($filters);

        return $this;
    }