Skip to content

Commit 09438ef

Browse files
committed
Fixed pattern for starts with / ends with,
added documentation for array based list
1 parent 676c505 commit 09438ef

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ For the get command you can filter by using the following url patterns
5656
| *`!^`* | Not Starts with (LIKE with wildcard on end) | ?filter[field!^]=hello | select ... where field not like 'hello%' |
5757
| *`!$`* | Not Ends with (LIKE with wildcard on start) | ?filter[field!$]=hello | select ... where field not like 'hello%' |
5858

59+
# In / Not In
60+
You can pass to the filters an array of values
61+
ie: `filter[user_id]=1||2||||4||7` or `filter[user_id!]=55||33`
62+
5963

6064
# Fields, Relationships, Sorting & Pagination
6165

src/UriParser.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,14 @@ private function appendQueryParameterAsBasicWhere($parameter)
171171
$operator = '!=';
172172
}
173173
if (in_array($operator, ['$', '^', '~'])) {
174-
$pre = in_array($operator, ['^', '~']) ? '%' : '';
175-
$post = in_array($operator, ['$', '~']) ? '%' : '';
174+
$pre = in_array($operator, ['$', '~']) ? '%' : '';
175+
$post = in_array($operator, ['^', '~']) ? '%' : '';
176176
$operator = 'like';
177177
$value = $pre.$value.$post;
178178
}
179179
if (in_array($operator, ['!$', '!^', '!~'])) {
180-
$pre = in_array($operator, ['!^', '!~']) ? '%' : '';
181-
$post = in_array($operator, ['!$', '!~']) ? '%' : '';
180+
$pre = in_array($operator, ['!$', '!~']) ? '%' : '';
181+
$post = in_array($operator, ['!^', '!~']) ? '%' : '';
182182
$operator = 'not like';
183183
$value = $pre.$value.$post;
184184
}

tests/LaravelApiControllerTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,14 @@ public function testQueryParsers()
116116
'type' => 'Basic',
117117
'key' => 'starts',
118118
'operator' => 'like',
119-
'value' => '%craig',
119+
'value' => 'craig%',
120120
]);
121121

122122
$this->assertEquals($parser->queryParameter('ends'), [
123123
'type' => 'Basic',
124124
'key' => 'ends',
125125
'operator' => 'like',
126-
'value' => 'smith%',
126+
'value' => '%smith',
127127
]);
128128

129129
$this->assertEquals($parser->queryParameter('ids'), [
@@ -169,14 +169,14 @@ public function testQueryParsers()
169169
'type' => 'Basic',
170170
'key' => 'notstart',
171171
'operator' => 'not like',
172-
'value' => '%fake',
172+
'value' => 'fake%',
173173
]);
174174

175175
$this->assertEquals($parser->queryParameter('notend'), [
176176
'type' => 'Basic',
177177
'key' => 'notend',
178178
'operator' => 'not like',
179-
'value' => 'notend%',
179+
'value' => '%notend',
180180
]);
181181

182182
$this->assertEquals($parser->queryParameter('notcontain'), [

0 commit comments

Comments
 (0)