<?php
namespace Incoviba\Repository\Venta;

use Incoviba\Common\Ideal;
use Incoviba\Common\Define;
use Incoviba\Common\Implement;
use Incoviba\Model;

class TipoEstadoPrecio extends Ideal\Repository
{
    public function __construct(Define\Connection $connection)
    {
        parent::__construct($connection);
        $this->setTable('tipo_estado_precio');
    }

    public function create(?array $data = null): Define\Model
    {
        $map = new Implement\Repository\MapperParser(['descripcion']);
        return $this->parseData(new Model\Venta\TipoEstadoPrecio(), $data, $map);
    }
    public function save(Define\Model $model): Define\Model
    {
        $model->id = $this->saveNew(
            ['descripcion'],
            [$model->descripcion]
        );
        return $model;
    }
    public function edit(Define\Model $model, array $new_data): Define\Model
    {
        return $this->update($model, ['descripcion'], $new_data);
    }
}
