public function actionDeepPageCopyAsTemplate()
    {
        $navId = (int) Yii::$app->request->getBodyParam('navId');

        if (empty($navId)) {
            throw new InvalidCallException("navId can not be empty.");
        }

        $nav = Nav::findOne($navId);

        if (!$nav) {
            throw new InvalidCallException("Unable to find the requested model.");
        }

        $model = $nav->createCopy(true);
        foreach ($nav->navItems as $item) {
            $newItem = new NavItem();
            $newItem->attributes = $item->toArray();
            $newItem->nav_id = $model->id;
            $newItem->parent_nav_id = $model->parent_nav_id;
            $newItem->title = $item->title . ' (template copy)';
            $newItem->alias = $item->alias . '-' . time();
            if ($newItem->save() && !empty($newItem->nav_item_type_id)) {
                $item->copyTypeContent($newItem);
            }
        }

        return true;
    }