Skip to content

Commit d15576a

Browse files
committed
Support where clause on read
1 parent f9190b3 commit d15576a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/DataMapper.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Simples\Model;
44

5+
use function array_merge;
56
use Exception;
67
use Simples\Data\Collection;
78
use Simples\Data\Error\SimplesRecordReadonlyError;
@@ -132,6 +133,12 @@ final public function read($record = null, string $alias = null, $trash = false,
132133

133134
$order = is_array($this->order) ? $this->order : [$this->order];
134135

136+
$where = off($this->getClauses(), 'where', []);
137+
if ($where) {
138+
$filters = array_merge($filters, $where);
139+
$values = array_merge($values, off($this->getClauses(), 'values', []));
140+
}
141+
135142
$array = $this
136143
->source($this->getCollection())
137144
->relation($this->parseReadRelations($this->fields))

0 commit comments

Comments
 (0)