Compare commits
37 Commits
aff0d4333d
...
2.3.0
Author | SHA1 | Date | |
---|---|---|---|
bc006f3e01 | |||
23c56f9511 | |||
4ccc38ffac | |||
ef1603bc4b | |||
8531658899 | |||
f19385ccc1 | |||
02f8bb0b4f | |||
d3771d8844 | |||
10e87b71a3 | |||
37c5a79d5a | |||
d12f3f7897 | |||
7fc7de7390 | |||
3bc54fb9d1 | |||
123d46d33c | |||
65c224c636 | |||
6cd26a88ea | |||
022ba575b7 | |||
c913f65b91 | |||
c8a7781c88 | |||
1505539e61 | |||
3087a48c43 | |||
43f545516d | |||
b757ed19b2 | |||
9dc71e4d77 | |||
c6806a1c62 | |||
6fd19a11be | |||
7c727d93e9 | |||
e02b8c4063 | |||
89d1db7a7e | |||
8dc0a27fd9 | |||
ae172b902c | |||
7f81b987c9 | |||
af801e769f | |||
c40baaad3f | |||
a82fdce64b | |||
8126b1f67d | |||
2177cb4652 |
@ -150,25 +150,35 @@ abstract class Repository implements RepositoryInterface
|
||||
public function fillData(Model $model, array $data): Model
|
||||
{
|
||||
foreach ($this->getRequired() as $column) {
|
||||
$m = 'set' . ucwords($column);
|
||||
$m = $this->getMethod($column, false);
|
||||
if (!method_exists($model, $m)) {
|
||||
continue;
|
||||
}
|
||||
$model->{$m}($data[$column]);
|
||||
}
|
||||
foreach ($this->getOptional() as $column) {
|
||||
if (isset($data[$column])) {
|
||||
$m = 'set' . ucwords($column);
|
||||
$model->{$m}($data[$column]);
|
||||
if (!isset($data[$column])) {
|
||||
continue;
|
||||
}
|
||||
$m = $this->getMethod($column, false);
|
||||
if (!method_exists($model, $m)) {
|
||||
continue;
|
||||
}
|
||||
$model->{$m}($data[$column]);
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
public function mapArray(Model $model, array $data): array
|
||||
{
|
||||
foreach ($this->getColumns() as $column) {
|
||||
$m = $this->getMethod($column);
|
||||
$val = $model->{$m}();
|
||||
if (isset($data[$column])) {
|
||||
continue;
|
||||
}
|
||||
$m = $this->getMethod($column);
|
||||
if (!method_exists($model, $m)) {
|
||||
continue;
|
||||
}
|
||||
$val = $model->{$m}();
|
||||
$data[$column] = $val;
|
||||
}
|
||||
return $data;
|
||||
@ -215,7 +225,10 @@ abstract class Repository implements RepositoryInterface
|
||||
{
|
||||
foreach ($this->getColumns() as $col) {
|
||||
if (isset($data[$col])) {
|
||||
$m = 'set' . ucwords($col);
|
||||
$m = $this->getMethod($col, false);
|
||||
if (!method_exists($model, $m)) {
|
||||
continue;
|
||||
}
|
||||
$model->{$m}($data[$col]);
|
||||
}
|
||||
}
|
||||
@ -232,9 +245,9 @@ abstract class Repository implements RepositoryInterface
|
||||
$query = $this->getQueryBuilder()
|
||||
->select()
|
||||
->from($this->getTable())
|
||||
->where([['id', '?']])
|
||||
->where(['id = ?'])
|
||||
->limit(1);
|
||||
return $this->load($this->getConnection()->execute($query, [$id])->getAsArray()[0]);
|
||||
return $this->load($this->getConnection()->execute($query, [$id])->getFirstAsArray());
|
||||
}
|
||||
public function fetchAll(): array
|
||||
{
|
||||
|
Reference in New Issue
Block a user