<?php
namespace Incoviba\Repository\Venta;

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

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

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


