<?php
namespace Incoviba\Repository\Inmobiliaria;

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

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

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