<?php
namespace Incoviba\Repository;

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

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

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