Version 3.0
New technologies
This commit is contained in:
32
api/src/Repository/Cuenta.php
Normal file
32
api/src/Repository/Cuenta.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?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()]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user