Use setcontent to filter with checkbox true or false

This commit is contained in:
Ivo Valchev
2020-12-01 11:15:48 +01:00
committed by Bob den Otter
parent 1aa117d43a
commit 772a3f1c8a
3 changed files with 16 additions and 6 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ class JsonHelper
*
* @return string|array
*/
public static function wrapJsonFunction(?string $where = null, ?string $slug = null, Connection $connection)
public static function wrapJsonFunction(?string $where = null, $slug = null, Connection $connection)
{
$version = new Version($connection);
+7 -1
View File
@@ -245,7 +245,7 @@ class QueryParameterParser
/**
* The default handler is the last to be run and handles simple value parsing.
*
* @param string|array $value
* @param string|array|bool $value
*/
public function defaultFilterHandler(string $key, $value, Expr $expr): Filter
{
@@ -272,6 +272,12 @@ class QueryParameterParser
}
$val = $this->parseValue((string) $value);
// @todo: Can this be refactored to avoid ugly override when $value is bool?
if (is_bool($value)) {
$val['value'] = $value;
}
$placeholder = $key . '_1';
$exprMethod = $val['operator'];
+8 -4
View File
@@ -178,12 +178,16 @@ class SelectQuery implements QueryInterface
{
// Change all params to lowercase, filter out empty ones
$this->params = array_filter(
Arr::mapRecursive($params, function ($a) {
return mb_strtolower((string) $a, 'utf-8');
Arr::mapRecursive($params, function ($param) {
if (is_bool($param)) {
return $param;
}
return mb_strtolower((string) $param, 'utf-8');
}
), function ($a) {
), function ($param) {
// ignore parameter if like statement is empty
return $a !== '%%';
return $param !== '%%';
});
$this->processFilters();