public function getUnitId() { if (isset($this->unit->id) && (int) $this->unit->id > 0) { return $this->unit->id; } else { return 0; } }