33 lines
860 B
PHP
33 lines
860 B
PHP
<?php
|
|
namespace Contabilidad\Repository;
|
|
|
|
use Common\Alias\Repository;
|
|
use Common\Concept\Model;
|
|
use Contabilidad\Model\Cuenta as BaseModel;
|
|
|
|
class Cuenta extends Repository
|
|
{
|
|
public function __construct()
|
|
{
|
|
$this->setTable('cuentas');
|
|
$this->setProperties(['id', 'nombre', 'tipo']);
|
|
}
|
|
|
|
public function load(array $data_row): Model
|
|
{
|
|
return (new BaseModel())
|
|
->setId($data_row['id']);
|
|
}
|
|
|
|
public function fetchByKey($key): Model
|
|
{
|
|
$query = "SELECT * FROM {$this->getTable()} WHERE `id` = ?";
|
|
return $this->load($this->getDatabase()->prepare($query)->execute($key)[0]);
|
|
}
|
|
public function delete(Model $model): void
|
|
{
|
|
$query = "DELETE FROM {$this->getTable()} WHERE `id` = ?";
|
|
$this->getDatabase()->prepare($query)->delete([$model->getId()]);
|
|
}
|
|
}
|