41 lines
1015 B
PHP
41 lines
1015 B
PHP
![]() |
<?php
|
||
|
namespace Incoviba\Model\Proyecto\Broker;
|
||
|
|
||
|
use Incoviba\Common;
|
||
|
use Incoviba\Model;
|
||
|
|
||
|
class Contract extends Common\Ideal\Model
|
||
|
{
|
||
|
public Model\Proyecto $project;
|
||
|
public Model\Proyecto\Broker $broker;
|
||
|
public float $commission;
|
||
|
protected array $states = [];
|
||
|
|
||
|
public function states(): array
|
||
|
{
|
||
|
if (!isset($this->states)) {
|
||
|
$this->states = $this->runFactory('states');
|
||
|
}
|
||
|
return $this->states;
|
||
|
}
|
||
|
|
||
|
protected Contract\State $current;
|
||
|
public function currentState(): Contract\State
|
||
|
{
|
||
|
if (!isset($this->current)) {
|
||
|
$this->current = last($this->states());
|
||
|
}
|
||
|
return $this->current;
|
||
|
}
|
||
|
|
||
|
protected function jsonComplement(): array
|
||
|
{
|
||
|
return [
|
||
|
'project_id' => $this->project->id,
|
||
|
'broker_rut' => $this->broker->rut,
|
||
|
'commission' => $this->commission,
|
||
|
'states' => $this->states(),
|
||
|
'current' => $this->currentState(),
|
||
|
];
|
||
|
}
|
||
|
}
|