Auth, Login, Home, Venta->Listados->Precios
This commit is contained in:
53
app/src/Repository/Region.php
Normal file
53
app/src/Repository/Region.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
namespace Incoviba\Repository;
|
||||
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Model;
|
||||
|
||||
class Region extends Ideal\Repository
|
||||
{
|
||||
public function __construct(Define\Connection $connection)
|
||||
{
|
||||
parent::__construct($connection);
|
||||
$this->setTable('region');
|
||||
}
|
||||
|
||||
public function create(?array $data = null): Define\Model
|
||||
{
|
||||
$map = [
|
||||
'descripcion' => [],
|
||||
'numeral' => [],
|
||||
'numeracion' => []
|
||||
];
|
||||
return $this->parseData(new Model\Region(), $data, $map);
|
||||
}
|
||||
public function save(Define\Model $model): Define\Model
|
||||
{
|
||||
$model->id = $this->saveNew(
|
||||
['descripcion', 'numeral', 'numeracion'],
|
||||
[$model->descripcion, $model->numeral, $model->numeracion]
|
||||
);
|
||||
return $model;
|
||||
}
|
||||
public function edit(Define\Model $model, array $new_data): Define\Model
|
||||
{
|
||||
return $this->update($model, ['descripcion', 'numeral', 'numeracion'], $new_data);
|
||||
}
|
||||
|
||||
public function fetchByDescripcion(string $descripcion): Define\Model
|
||||
{
|
||||
$query = "SELECT * FROM `{$this->getTable()}` WHERE `descripcion` = ?";
|
||||
return $this->fetchOne($query, [$descripcion]);
|
||||
}
|
||||
public function fetchByNumeral(string $numeral): Define\Model
|
||||
{
|
||||
$query = "SELECT * FROM `{$this->getTable()}` WHERE `numeral` = ?";
|
||||
return $this->fetchOne($query, [$numeral]);
|
||||
}
|
||||
public function fetchByNumeracion(int $numeracion): Define\Model
|
||||
{
|
||||
$query = "SELECT * FROM `{$this->getTable()}` WHERE `numeracion` = ?";
|
||||
return $this->fetchOne($query, [$numeracion]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user