Skip to content

Commit b475545

Browse files
committed
Suporte order default
1 parent 05cc91d commit b475545

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/DataMapper.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,19 @@
1010
use Simples\Model\Error\SimplesHookError;
1111
use Simples\Persistence\Field;
1212
use Simples\Persistence\Filter;
13+
use function is_array;
1314

1415
/**
1516
* Class DataMapper
1617
* @package Simples\Model
1718
*/
1819
abstract class DataMapper extends ModelAbstract
1920
{
21+
/**
22+
* @var string
23+
*/
24+
protected $order = '';
25+
2026
/**
2127
* DataMapper constructor
2228
*/
@@ -121,11 +127,15 @@ final public function read($record = null, string $alias = null, $trash = false,
121127
if ($clean) {
122128
$fields = $this->clear($fields);
123129
}
130+
131+
$order = is_array($this->order) ? $this->order : [$this->order];
132+
124133
$array = $this
125134
->source($this->getCollection())
126135
->relation($this->parseReadRelations($this->fields))
127136
->fields($fields)
128-
->where($filters) // TODO: needs review
137+
->order($order)
138+
->where($filters)// TODO: needs review
129139
->recover($values);
130140

131141
$this->reset();

0 commit comments

Comments
 (0)