Correcciones
This commit is contained in:
@ -14,23 +14,27 @@ class State extends Common\Ideal\Repository
|
||||
|
||||
public function getTable(): string
|
||||
{
|
||||
return 'brokers_contract_states';
|
||||
return 'broker_contract_states';
|
||||
}
|
||||
|
||||
public function create(?array $data = null): Model\Proyecto\Broker\Contract\State
|
||||
{
|
||||
$map = (new Common\Implement\Repository\MapperParser(['type']))
|
||||
$map = (new Common\Implement\Repository\MapperParser())
|
||||
->register('contract_id', (new Common\Implement\Repository\Mapper())
|
||||
->setProperty('contract')
|
||||
->setFunction(function($data) {
|
||||
return $this->contractRepository->fetchById($data['contract_id']);
|
||||
}))
|
||||
->register('type', (new Common\Implement\Repository\Mapper())
|
||||
->setFunction(function($data) {
|
||||
return Model\Proyecto\Broker\Contract\State\Type::from($data['type']);
|
||||
}))
|
||||
->register('date', new Common\Implement\Repository\Mapper\DateTime('date'));
|
||||
return $this->parseData(new Model\Proyecto\Broker\Contract\State(), $data, $map);
|
||||
}
|
||||
public function save(Common\Define\Model $model): Model\Proyecto\Broker\Contract\State
|
||||
{
|
||||
$model->id = $this->saveNew(['contract_id', 'date', 'type'], [$model->contract->id, $model->date->format('Y-m-d'), $model->type]);
|
||||
$model->id = $this->saveNew(['contract_id', 'date', 'type'], [$model->contract->id, $model->date->format('Y-m-d'), $model->type->value]);
|
||||
return $model;
|
||||
}
|
||||
public function edit(Common\Define\Model $model, array $new_data): Model\Proyecto\Broker\Contract\State
|
||||
@ -38,6 +42,11 @@ class State extends Common\Ideal\Repository
|
||||
return $this->update($model, ['contract_id', 'date', 'type'], $new_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $contract_id
|
||||
* @return array
|
||||
* @throws Common\Implement\Exception\EmptyResult
|
||||
*/
|
||||
public function fetchByContract(int $contract_id): array
|
||||
{
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
@ -46,6 +55,12 @@ class State extends Common\Ideal\Repository
|
||||
->where('contract_id = :contract_id');
|
||||
return $this->fetchMany($query, ['contract_id' => $contract_id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $contract_id
|
||||
* @return Model\Proyecto\Broker\Contract\State
|
||||
* @throws Common\Implement\Exception\EmptyResult
|
||||
*/
|
||||
public function fetchActiveByContract(int $contract_id): Model\Proyecto\Broker\Contract\State
|
||||
{
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
|
Reference in New Issue
Block a user