public function getMenu() { $moduleName = AbstractModel::moduleName(static::className()); $model = $this->findModel(); $uniqueKey = 0; $items = $model::find()->orderBy(['lft' => SORT_ASC])->asArray()->all(); foreach ($items as &$item) { $uniqueKey++; $nodeId = $uniqueKey . '-id-' . $item['id']; $item['nodeAttributes'] = ['id' => $nodeId, 'text' => $item['name'], 'type' => 'folder', 'active' => \Yii::$app->request->get('id') == $item['id'], 'a_attr' => ['data-id' => $nodeId, 'href' => ["/{$moduleName}/category/update", 'id' => $item['id']]]]; } $treeWidget = new ARTreeMenuWidget(['items' => $items, 'view' => 'nested']); return $treeWidget->run(); }
/** * Relative path for saving model files. * @return string path. */ public function getStoragePath() { $moduleName = AbstractModel::moduleName(static::className()); $owner_id = $this->getAttribute('owner_id') ?: Yii::$app->user->id; return "@app/web/files/{$owner_id}/{$moduleName}/" . $this->formName() . '/' . $this->id; }
/** * Relative path for saving model files. * @return string path. */ public function getStoragePath() { $moduleName = AbstractModel::moduleName(static::className()); return "@app/web/files/{$moduleName}/" . $this->formName() . '/' . $this->id; }