Actualizacion de Repos
This commit is contained in:
@ -14,6 +14,11 @@ class Data extends Common\Ideal\Repository
|
||||
parent::__construct($connection);
|
||||
}
|
||||
|
||||
public function getTable(): string
|
||||
{
|
||||
return 'broker_data';
|
||||
}
|
||||
|
||||
public function create(?array $data = null): Model\Proyecto\Broker\Data
|
||||
{
|
||||
$map = (new Common\Implement\Repository\MapperParser())
|
||||
@ -26,13 +31,15 @@ class Data extends Common\Ideal\Repository
|
||||
->setProperty('representative')
|
||||
->setDefault(null)
|
||||
->setFunction(function($data) {
|
||||
if ($data['representative_rut'] == null) return null;
|
||||
try {
|
||||
return $this->personaRepository->fetchById($data['representative_rut']);
|
||||
} catch (Common\Implement\Exception\EmptyResult) {
|
||||
return null;
|
||||
}
|
||||
}))
|
||||
->register('legalName', (new Common\Implement\Repository\Mapper())
|
||||
->register('legal_name', (new Common\Implement\Repository\Mapper())
|
||||
->setProperty('legalName')
|
||||
->setDefault(null));
|
||||
return $this->parseData(new Model\Proyecto\Broker\Data(), $data, $map);
|
||||
}
|
||||
@ -45,15 +52,15 @@ class Data extends Common\Ideal\Repository
|
||||
}
|
||||
public function edit(Common\Define\Model $model, array $new_data): Model\Proyecto\Broker\Data
|
||||
{
|
||||
return $this->update($model, ['broker_rut', 'representative_rut', 'legal_name'], $new_data);
|
||||
return $this->update($model, ['representative_rut', 'legal_name'], $new_data);
|
||||
}
|
||||
|
||||
public function fetchByBroker(int $brokerRut): Model\Proyecto\Broker\Data
|
||||
public function fetchByBroker(int $broker_rut): Model\Proyecto\Broker\Data
|
||||
{
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
->select()
|
||||
->from($this->getTable())
|
||||
->where('broker_rut = :broker_rut');
|
||||
return $this->fetchOne($query, ['broker_rut' => $brokerRut]);
|
||||
return $this->fetchOne($query, ['broker_rut' => $broker_rut]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user