38 lines
1.2 KiB
PHP
38 lines
1.2 KiB
PHP
<?php
|
|
namespace Incoviba\Repository\Proyecto;
|
|
|
|
use Incoviba\Common\Ideal;
|
|
use Incoviba\Common\Define;
|
|
use Incoviba\Common\Implement;
|
|
use Incoviba\Model;
|
|
|
|
class Etapa extends Ideal\Repository
|
|
{
|
|
public function __construct(Define\Connection $connection)
|
|
{
|
|
parent::__construct($connection);
|
|
$this->setTable('etapa_proyecto');
|
|
}
|
|
|
|
public function create(?array $data = null): Model\Proyecto\Etapa
|
|
{
|
|
$map = new Implement\Repository\MapperParser(['descripcion', 'orden']);
|
|
return $this->parseData(new Model\Proyecto\Etapa(), $data, $map);
|
|
}
|
|
public function save(Define\Model $model): Model\Proyecto\Etapa
|
|
{
|
|
$model->id = $this->saveNew(['descripcion', 'orden'], [$model->descripcion, $model->orden]);
|
|
return $model;
|
|
}
|
|
public function edit(Define\Model $model, array $new_data): Model\Proyecto\Etapa
|
|
{
|
|
return $this->update($model, ['descripcion', 'orden'], $new_data);
|
|
}
|
|
|
|
public function fetchByDescripcion(string $descripcion): Model\Proyecto\Etapa
|
|
{
|
|
$query = "SELECT * FROM `{$this->getTable()}` WHERE `descripcion` = ?";
|
|
return $this->fetchOne($query, [$descripcion]);
|
|
}
|
|
}
|