Get all models by key/value.

@param string $key
@param string $value

@return Collection
969107
public function allBy($key, $value)
    {
        if (!request('preview')) {
            $this->published();
        }

        return $this->executeCallback(static::class, __FUNCTION__, func_get_args(), function () use ($key, $value) {
            return $this->prepareQuery($this->createModel())
                ->where($key, $value)
                ->order()
                ->get();
        });
    }
1200984
public function filter($key, $value = null)
    {
        $this->invalidateCachedResults();
        return $this->parentFilter($key, $value);
    }
311149
public function set($key, $value): ArrayCollection
    {
        if ($key === null) {
            $this->items[] = $value;
        } else {
            $this->items[$key] = $value;
        }

        return $this;
    }
520875
public static function gets($keys = null)
    {
        $noInitModel = static::buildNoInitModel();
        $query = static::find();
        if ($keys == null) {
            $models = $query->all();
        } elseif (is_array($keys)) {
            $array = [];
            foreach ($keys as $key) {
                if (is_string($key) && strlen($key)) {
                    $array[] = $key;
                }
            }
            $models = $query->where([$noInitModel->idAttribute => $array])->all();
        }
        $result = [];
        foreach ($models as $key => $model) {
            $result[$model->key] = $model->value;
        }
        return $result;
    }
609075
public static function keys($value)
    {

        if (is_array($value)) {
            return array_keys($value);
        }

        if (!is_object($value)) {
            return [];
        }

        if (!$value instanceof Traversable) {
            return array_keys(get_object_vars($value));
        }

        return array_keys(iterator_to_array($value, true));

    }
1126362
public function value($key, $value)
    {
        $this->values = array_merge($this->values ?? [], [$this->trimName($key) => $value]);
        return $this;
    }
282816
public function getKey($value) {
		foreach ($this->collection as $k => $v) {
			if ($v === $value) {
				return $k;
			}
		}
		
		return null;
	}
74619
protected function getBy($key, $value)
    {
        $stmt = $this->pdo->prepare('SELECT * FROM ' . $this->tableName . ' WHERE ' . $key . ' = :value');
        $result = $stmt->execute(['value'=>$value]);
        return $this->processRow($stmt->fetch(PDO::FETCH_ASSOC));
    }
969118
protected function getGroupByKey( $group, $key, $value )
    {
        if ( !is_string( $group ) && is_callable( $group ) )
        {
            return $group( $value, $key );
        }

        return Util::dataGet( $value, $group );
    }
1166852
public static function get($key, $value = null)
    {
        if (self::check($key, !is_null($value))) {
            return self::reach($key, $value);
        }

        static::set($key, $value);

        return $value;
    }
454263
public function with($value)
    {
        $withs = explode(',', $value);
        $model = $this->builder->getModel();
        $withs = collect($withs)->filter(function ($with) use($model) {
            if (str_contains($with, '.')) return ($model->{explode('.', $with)[0]}() instanceof Relation);
            return ($model->{$with}() instanceof Relation);
        })->toArray();
        return $this->builder->when(count($withs), function (Builder $query) use($withs) {
            $query->with($withs);
        });
    }
1219778
public function with($key, $value = null)
    {
        $values = (is_array($key) || $key instanceof Traversable) ? $key : [$key => $value];

        return $this->copy()->update($values);
    }
1228201
public function search(string $key, string $value)
    {
        return $this->getRepository()->findBy(['key' => $key, 'value' => $value]);
    }
380772
public function findByKeyAndValue(string $key, $value): MapInterface
    {
        return $this->find(function (MapInterface $item) use ($key, $value): bool {
            return $item->get($key) === $value;
        });
    }
682954
public function getByValue(string $key, $value)
    {
        return array_filter($this->items, function ($val) use ($key, $value) {
            return $val[$this->normalizeKey($key)] === $value;
        });
    }
517378
public function getManyBy($key, $value, array $with = array())
    {
        return $this->make($with)->where($key, '=', $value)->get();
    }
973837
public function set($key, $value)
    {
        $keys = explode('.', $key);

        $data = $this->getAll();

        $resource = &$data;
        foreach ($keys as $key) {
            if (!isset($resource[$key]) || !is_array($resource[$key])) {
                $resource[$key] = [];
            }
            $resource = &$resource[$key];
        }
        $resource = $value;

        $this->setAll($data);

        return $this;
    }