Exemplo n.º 1
0
 public function eventBeforeDelete($event)
 {
     $items = Article::find()->where(['cat_id' => $this->id])->all();
     if (count($items) > 0) {
         $this->addError('id', Module::t('cat_delete_error'));
         $event->isValid = false;
         return;
     }
     $event->isValid = true;
 }
Exemplo n.º 2
0
 public function rules()
 {
     return [['title', 'required', 'message' => Module::t('tag_title_create_error')]];
 }
Exemplo n.º 3
0
 public function getMenu()
 {
     return $this->node(Module::t('news'), 'local_library')->group(Module::t('news_administrate'))->itemApi(Module::t('article'), 'newsadmin-article-index', 'edit', 'api-news-article')->itemApi(Module::t('cat'), 'newsadmin-cat-index', 'bookmark_border', 'api-news-cat')->itemApi(Module::t('tag'), 'newsadmin-tag-index', 'label_outline', 'api-news-tag')->menu();
 }
Exemplo n.º 4
0
 public function ngRestConfig($config)
 {
     $this->ngRestConfigDefine($config, 'list', ['title', 'timestamp_create', 'image_id']);
     $config->list->field('cat_id', Module::t('article_cat_id'))->selectClass('\\newsadmin\\models\\Cat', 'id', 'title');
     $this->ngRestConfigDefine($config, 'update', ['title', 'text', 'timestamp_create', 'timestamp_display_from', 'is_display_limit', 'timestamp_display_until', 'image_id', 'image_list', 'file_list']);
     $config->update->field('cat_id', Module::t('article_cat_id'))->selectClass('\\newsadmin\\models\\Cat', 'id', 'title');
     $config->update->extraField('tags', Module::t('article_tag'))->checkboxRelation(\newsadmin\models\Tag::className(), 'news_article_tag', 'article_id', 'tag_id', ['title']);
     $config->create->copyFrom('update', ['timestamp_display_until']);
     $config->delete = true;
     return $config;
 }