Actualizacion de Repos
This commit is contained in:
@ -13,6 +13,11 @@ class Contract extends Common\Ideal\Repository
|
||||
parent::__construct($connection);
|
||||
}
|
||||
|
||||
public function getTable(): string
|
||||
{
|
||||
return 'broker_contracts';
|
||||
}
|
||||
|
||||
public function create(?array $data = null): Model\Proyecto\Broker\Contract
|
||||
{
|
||||
$map = (new Common\Implement\Repository\MapperParser(['commission']))
|
||||
@ -90,4 +95,4 @@ class Contract extends Common\Ideal\Repository
|
||||
{
|
||||
return 'INNER JOIN (SELECT bcs1.* FROM broker_contract_states bcs1 INNER JOIN (SELECT MAX(id) AS id, contract_id FROM broker_contract_states GROUP BY contract_id) bcs0 ON bcs0.id = bcs1.id) bcs ON bcs.contract = a.id';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,11 @@ class State extends Common\Ideal\Repository
|
||||
parent::__construct($connection);
|
||||
}
|
||||
|
||||
public function getTable(): string
|
||||
{
|
||||
return 'brokers_contract_states';
|
||||
}
|
||||
|
||||
public function create(?array $data = null): Model\Proyecto\Broker\Contract\State
|
||||
{
|
||||
$map = (new Common\Implement\Repository\MapperParser(['type']))
|
||||
@ -49,4 +54,4 @@ class State extends Common\Ideal\Repository
|
||||
->where('contract_id = :contract_id AND type = :type');
|
||||
return $this->fetchOne($query, ['contract_id' => $contract_id, 'type' => Model\Proyecto\Broker\Contract\State\Type::ACTIVE]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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