/** * Возвращает всех детей выше * Возвращает родословную от человека указанного в модели до Я (чей род) * * @param int $id * * @return array * [ * [ * 'name' => string, (если имя не указано или не заполнены данные о человеке, то здесь = null) * 'id' => int, идентификатор рода * ], ... * ] */ private function getRodPathCircle($id) { $ret = []; $childId = self::calcChild($id); if ($childId == 0) { return $ret; } else { $class = self::find(['user_id' => $this->getField('user_id'), 'rod_id' => $childId]); if (is_null($class)) { $ret[] = ['id' => $childId, 'name' => null]; $class = new self(['user_id' => $this->getField('user_id'), 'rod_id' => $childId]); } else { $ret[] = ['id' => $childId, 'name' => $class->getName()]; } $path = $class->getRodPathCircle($childId); return ArrayHelper::merge($path, $ret); } }