protected function generateItems() { $moduleName = Module::moduleName($this); $model = Module::getModel($this, 'Category', ['widgets' => 'models']); $items = $model::find()->orderBy(['lft' => SORT_ASC])->asArray()->all(); foreach ($items as &$item) { $uniqueKey = self::$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']]]]; } return $items; }
/** * Relative path for saving model files. * @return string path. */ public function getStoragePath() { $moduleName = \bariew\postModule\Module::moduleName($this); $user_id = $this->getAttribute('user_id') ?: Yii::$app->user->id; return "@app/web/files/{$user_id}/{$moduleName}/" . $this->formName() . '/' . $this->id; }
/** * Relative path for saving model files. * @return string path. */ public function getStoragePath() { $moduleName = \bariew\postModule\Module::moduleName($this); return "@app/web/files/{$moduleName}/" . $this->formName() . '/' . $this->id; }