Compare commits

...

2 Commits

Author SHA1 Message Date
Maik Müller ac2ecfac48 let's test live 2021-09-19 21:32:45 +02:00
Maik Müller 2f0096cab2 remove console.log 2021-09-19 14:10:18 +02:00
3 changed files with 66 additions and 4 deletions

View File

@ -12,4 +12,9 @@ return [
'log_channel' => 'default',
// Types
// Search
];

57
config/types.md Normal file
View File

@ -0,0 +1,57 @@
# Regex tmpl
([\w_-]*)\[([\w]*)\]=([\w_-]*)
# Search #
The search filter supports exact, partial, start, end, and word_start matching strategies:
partial strategy uses LIKE %text% to search for fields that contain text.
start strategy uses LIKE text% to search for fields that start with text.
end strategy uses LIKE %text to search for fields that end with text.
word_start strategy uses LIKE text% OR LIKE % text% to search for fields that contain words starting with text.
Syntax: ?property[]=foo&property[]=bar
optional brackets!
([\w_-]*)(\[(i?exact|i?partial|i?start|i?end|i?word_start)?\])?=([\w_\-\d]*) /gm
# Date Filter #
The date filter allows to filter a collection by date intervals.
Syntax: ?property[<after|before|strictly_after|strictly_before>]=value
The value can take any date format supported by the \DateTime constructor.
The after and before filters will filter including the value whereas strictly_after and strictly_before will
filter excluding the value.
# Boolean Fitler #
The boolean filter allows you to search on boolean fields and values.
Syntax: ?property=<true|false|1|0>
# Numeric Filter #
The numeric filter allows you to search on numeric fields and values.
Syntax: ?property=<int|bigint|decimal...>
# Range Filter #
The range filter allows you to filter by a value lower than, greater than, lower than or equal, greater than or equal and between two values.
Syntax: ?property[<lt|gt|lte|gte|between>]=value
# Exists Filter
The exists filter allows you to select items based on a nullable field value. It will also check the emptiness of a collection association.
Syntax: ?exists[property]=<true|false|1|0>

View File

@ -21,11 +21,12 @@ trait ColumnMultiFilter
public function scopeMultiFilter(Builder $query): Builder
{
//Log::debug("Request: " . print_r(request()->all(), true));
if (request()->has('filter')) {
$filters = request()->get('filter');
$this->log('Filter found: ' . print_r($filters, true));
$this->log('Filter found: '.print_r($filters, true));
return $this->filterQueryBuilder($query, $filters);
@ -146,7 +147,7 @@ trait ColumnMultiFilter
}
} else {
Log::debug('where ..'.print_r([$column, $operator, $value, $logic], true));
$query = $this->addWhereIfValid($query, $column, $operator, $value, $logic);
}
@ -177,11 +178,10 @@ trait ColumnMultiFilter
private function addWhereIfValid(Builder $query, string $column, string $operator, string $value, string $logic)
{
if (trim($operator) === 'like' && trim($value) === '') {
if (trim($value) === '') {
return $query;
}
Log::debug('add where now');
$query->where($column, $operator, $value, $logic);
return $query;