states) or count($this->states) === 0) { $this->states = $this->runFactory('states'); } return $this->states; } protected ?Contract\State $current; public function currentState(): ?Contract\State { if (!isset($this->current)) { try { $this->current = last($this->states()); } catch (\TypeError $error) { $this->current = null; } } 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(), ]; } }