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();
 }
예제 #2
0
 /**
  * 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;
 }
예제 #3
0
 /**
  * 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;
 }