Auth, Login, Home, Venta->Listados->Precios

This commit is contained in:
Juan Pablo Vial
2023-07-24 20:55:26 -04:00
parent d9d5a15376
commit 1a7b10ce3c
130 changed files with 4302 additions and 0 deletions

View File

@ -0,0 +1,48 @@
<?php
namespace Incoviba\Repository;
use Incoviba\Common\Define;
use Incoviba\Common\Ideal\Repository;
use Incoviba\Model;
class Direccion extends Repository
{
public function __construct(Define\Connection $connection, protected Comuna $comunaRepository)
{
parent::__construct($connection);
$this->setTable('direccion');
}
public function create(?array $data = null): Define\Model
{
$map = [
'calle' => [],
'numero' => [],
'extra' => [],
'comuna' => [
'function' => function($data) {
return $this->comunaRepository->fetchById($data['comuna']);
}
]
];
return $this->parseData(new Model\Direccion(), $data, $map);
}
public function save(Define\Model $model): Define\Model
{
$model->id = $this->saveNew(
['calle', 'numero', 'extra', 'comuna'],
[$model->calle, $model->numero, $model->extra, $model->comuna->id]
);
return $model;
}
public function edit(Define\Model $model, array $new_data): Define\Model
{
return $this->update($model, ['calle', 'numero', 'extra', 'comuna'], $new_data);
}
public function fetchByCalleAndNumero(string $calle, int $numero): array
{
$query = "SELECT * FROM `{$this->getTable()}` WHERE `calle` = ? AND `numero` = ?";
return $this->fetchMany($query, [$calle, $numero]);
}
}