/** * Действия * @return array */ public function actions() { $class = NewsSection::className(); return ['index' => ['class' => crud\TAdmin::className(), 'modelClass' => $class], 'create' => ['class' => crud\TCreate::className(), 'modelClass' => $class], 'update' => ['class' => crud\TUpdate::className(), 'modelClass' => $class], 'view' => ['class' => crud\View::className(), 'modelClass' => $class], 'delete' => ['class' => crud\TDelete::className(), 'modelClass' => $class], 'groupdelete' => ['class' => crud\TGroupDelete::className(), 'modelClass' => $class], 'up' => ['class' => crud\TUp::className(), 'modelClass' => $class], 'down' => ['class' => crud\TDown::className(), 'modelClass' => $class], 'replace' => ['class' => crud\TReplace::className(), 'modelClass' => $class], 'editable' => ['class' => crud\XEditable::className(), 'modelClass' => $class]]; }
/** * Связь с категориями * @return \yii\db\ActiveQueryInterface */ public function getSections() { return $this->hasMany(NewsSection::className(), ['id' => 'section_id'])->viaTable('news_to_sections', ['news_id' => 'id']); }
/** * Возвращает категории новостей для dropDown * @return array * @throws \yii\base\InvalidConfigException */ public function getSectionsList() { $model = \Yii::createObject(NewsSection::className()); return $model->getDataByParent(); }
<?php use app\modules\news\models; return ['controllerMap' => ['migrate' => ['migrationLookup' => ['@webapp/modules/news/migrations']]], 'modules' => ['news' => ['class' => app\modules\news\News::className(), 'controllerNamespace' => 'app\\modules\\news\\controllers', 'modules' => ['admin' => ['class' => app\modules\news\modules\admin\Admin::className(), 'controllerNamespace' => 'app\\modules\\news\\modules\\admin\\controllers', 'menuItems' => function () { return [['label' => Yii::t('news/app', 'News module'), 'icon' => 'glyphicon glyphicon-align-justify', 'items' => [['label' => Yii::t('news/app', 'News'), 'url' => ['/admin/news/news'], "permission" => ["listModels", ["model" => Yii::createObject(models\News::className())]]], ['label' => Yii::t('news/app', 'News sections'), 'url' => ['/admin/news/news-section'], "permission" => ["listModels", ["model" => Yii::createObject(models\NewsSection::className())]]]]]]; }]]]], 'components' => ['i18n' => ['translations' => ['news/*' => ['class' => 'yii\\i18n\\PhpMessageSource', 'basePath' => '@webapp/modules/news/messages', 'fileMap' => ['news/app' => 'app.php']]]], 'urlManager' => ['rules' => ['news/<section:[A-z0-9_-]+>/<code:[A-z0-9_-]+>' => 'news/news/detail', 'news/<section:[A-z0-9_-]+>' => 'news/news/index', 'news' => 'news/news/index']]]];