Compare commits
5 Commits
574918f1cc
...
8b8aa79b6d
Author | SHA1 | Date | |
---|---|---|---|
8b8aa79b6d | |||
e2d670a38c | |||
4d85b39cab | |||
33c90f06dd | |||
3771af0282 |
@ -25,7 +25,7 @@ abstract class Repository implements Define\Repository
|
||||
public function load(array $data_row): Define\Model
|
||||
{
|
||||
$model = $this->create($data_row);
|
||||
$model->{$this->getKey()} = $data_row[$this->getKey()];
|
||||
$this->setIndex($model, $data_row[$this->getKey()]);
|
||||
return $model;
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ abstract class Repository implements Define\Repository
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
->delete()->from($this->getTable())
|
||||
->where("{$this->getKey()} = ?");
|
||||
$this->connection->execute($query, [$model->{$this->getKey()}]);
|
||||
$this->connection->execute($query, [$this->getIndex($model)]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -73,6 +73,17 @@ abstract class Repository implements Define\Repository
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
protected function setIndex(Define\Model &$model, mixed $value): Repository
|
||||
{
|
||||
$model->{$this->getKey()} = $value;
|
||||
return $this;
|
||||
}
|
||||
protected function getIndex(Define\Model $model): mixed
|
||||
{
|
||||
return $model->id;
|
||||
}
|
||||
|
||||
protected function parseData(Define\Model $model, ?array $data, Implement\Repository\MapperParser $data_map): Define\Model
|
||||
{
|
||||
if ($data === null) {
|
||||
@ -146,9 +157,9 @@ abstract class Repository implements Define\Repository
|
||||
->update($this->getTable())
|
||||
->set($columns_string)
|
||||
->where("{$this->getKey()} = ?");
|
||||
$values []= $model->{$this->getKey()};
|
||||
$values []= $this->getIndex($model);
|
||||
$this->connection->execute($query, $values);
|
||||
return $this->fetchById($model->{$this->getKey()});
|
||||
return $this->fetchById($this->getIndex($model));
|
||||
}
|
||||
protected function fetchOne(string $query, ?array $data = null): Define\Model
|
||||
{
|
||||
|
@ -73,4 +73,16 @@ class Detalle extends Ideal\Repository
|
||||
{
|
||||
return 'movimiento_id';
|
||||
}
|
||||
protected function setIndex(Define\Model &$model, mixed $value): Ideal\Repository
|
||||
{
|
||||
if (!isset($model->movimiento)) {
|
||||
$model->movimiento = $this->movimientoRepository->fetchById($value);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function getIndex(Define\Model $model): string
|
||||
{
|
||||
return $model->movimiento->id;
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ class Santander extends Banco
|
||||
'Descripción' => 'glosa',
|
||||
'Nº Docu' => 'documento',
|
||||
'Cheques y Otros Cargos' => 'cargo',
|
||||
'Cheques y Cargos' => 'cargo',
|
||||
'Depósitos y Abonos' => 'abono',
|
||||
'Saldo' => 'saldo',
|
||||
'Categoría' => 'categoria',
|
||||
@ -56,6 +57,7 @@ class Santander extends Banco
|
||||
|
||||
$valueColumns = [
|
||||
'Cheques y Otros Cargos',
|
||||
'Cheques y Cargos',
|
||||
'Depósitos y Abonos',
|
||||
'Saldo'
|
||||
];
|
||||
|
Reference in New Issue
Block a user