Agregar Proveedor

This commit is contained in:
Juan Pablo Vial
2024-12-03 16:45:20 -03:00
parent 5b44260245
commit 42e1dcdff7
19 changed files with 473 additions and 283 deletions

View File

@ -1,28 +1,28 @@
<?php
namespace Incoviba\Service;
use Psr\Log\LoggerInterface;
use Incoviba\Common\Ideal;
use Incoviba\Common\Implement;
use Incoviba\Model;
use Incoviba\Repository;
use Psr\Log\LoggerInterface;
class Persona extends Ideal\Service
{
public function __construct(LoggerInterface $logger, protected Repository\Persona $personaRepository,
protected Repository\DatosPersona $datosPersonaRepository)
public function __construct(LoggerInterface $logger, protected Repository\Persona $personaRepository,
protected Repository\Persona\Datos $datosPersonaRepository)
{
parent::__construct($logger);
}
public function getByRut(int $rut): Model\Persona
public function getById(int $rut): Model\Persona
{
return $this->process($this->personaRepository->fetchByRut($rut));
return $this->process($this->personaRepository->fetchById($rut));
}
public function add(array $data): Model\Persona
{
try {
$persona = $this->personaRepository->fetchByRut($data['rut']);
$persona = $this->personaRepository->fetchById($data['rut']);
} catch (Implement\Exception\EmptyResult) {
$persona = $this->personaRepository->create($data);
$persona = $this->personaRepository->save($persona);