Skip to content

Commit e103300

Browse files
committed
Added ability to get all filters on a query.
1 parent 625e66c commit e103300

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/Query/Builder.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,6 +1229,16 @@ public function addFilter($type, array $bindings)
12291229
return $this;
12301230
}
12311231

1232+
/**
1233+
* Get all the filters on the query.
1234+
*
1235+
* @return array
1236+
*/
1237+
public function getFilters()
1238+
{
1239+
return $this->filters;
1240+
}
1241+
12321242
/**
12331243
* Clear the query filters.
12341244
*

tests/Query/BuilderTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,28 @@ public function test_adding_invalid_filter_type_throws_exception()
102102
]);
103103
}
104104

105+
public function test_get_filters()
106+
{
107+
$b = $this->newBuilder();
108+
109+
$b->where('foo', '=', 'bar');
110+
$b->orWhere('baz', '=', 'foo');
111+
112+
$this->assertEquals([
113+
'and' => [[
114+
'field' => 'foo',
115+
'operator' => '=',
116+
'value' => '\62\61\72',
117+
]],
118+
'or' => [[
119+
'field' => 'baz',
120+
'operator' => '=',
121+
'value' => '\66\6f\6f',
122+
]],
123+
'raw' => [],
124+
], $b->getFilters());
125+
}
126+
105127
public function test_clear_filters()
106128
{
107129
$b = $this->newBuilder();

0 commit comments

Comments
 (0)