'index/wide_widget', self::TEXT_NEWS_WIDGET=>'index/text_news_widget', self::TOPIC_WIDGET=>'index/topic_widget', self::IMAGINE_NEWS_WIDGET=>'index/partners_news', self::COLORFUL_WIDGET=>'index/colorful_widget', self::MAY9=>'index/wide_widget_9may', ]; /** * {@inheritdoc} */ public static function tableName() { return 'design'; } /** * {@inheritdoc} */ public function rules() { return [ [['parent_id','active','type','design'], 'required'], [['parent_id', 'design', 'order'], 'integer'], [['active'], 'string'], [['type'], 'string', 'max' => 64], [['title', 'url'], 'string', 'max' => 255], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'id', 'parent_id' => 'ресурсы', 'type' => 'тип ресурса', 'design' => 'вариант отображения', 'title' => 'заголовок', 'order' => 'сортировка', 'url' => 'URL', 'active' => 'спрятать', ]; } /** * {@inheritdoc} * @return status. */ public function Active($id, $state = -1) { if( $state < 0 ){ $this->active = ($this->active == 'Y')?'N':'Y'; }else{ $this->active = $state; } return $this->save(); } private $_parent = false; /** * @return NewsTopic|Story|NULL */ public function getParent() { if(!$this->_parent){ switch ($this->type){ case "topic": $this->_parent = NewsTopic::find()->alias("t")->andWhere(["t.id"=>$this->parent_id])->one(); break; default: $this->_parent = Story::find()->alias("s")->andWhere(['s.id'=>$this->parent_id])->one(); } } return $this->_parent; } }