Merge pull request #1889 from SevanNerse/search-string

it should parse date-related parameters
This commit is contained in:
Cüneyt Şentürk 2021-02-24 18:51:32 +03:00 committed by GitHub
commit 1677a930ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,8 +7,9 @@ trait SearchString
/**
* Get the value of a name in search string
* Example: search=type:customer year:2020 account_id:20
* Example: issued_at>=2021-02-01 issued_at<=2021-02-10 account_id:49
*
* @return string
* @return string|array
*/
public function getSearchStringValue($name, $default = '', $input = null)
{
@ -18,21 +19,29 @@ trait SearchString
$input = request('search');
}
//$manager = $this->getSearchStringManager();
//$parsed = $manager->parse($input);
// $manager = $this->getSearchStringManager();
// $parsed = $manager->parse($input);
$columns = explode(' ', $input);
foreach ($columns as $column) {
$variable = explode(':', $column);
$variable = preg_split('/:|>?<?=/', $column);
if (empty($variable[0]) || ($variable[0] != $name) || empty($variable[1])) {
continue;
}
if (strpos($column, ':')) {
$value = $variable[1];
$value = $variable[1];
break;
}
break;
if (!is_array($value)) {
$value = [];
}
$value[] = $variable[1];
}
return $value;