diff --git a/components/CategoryModel.php b/components/CategoryModel.php index 6c7f986..457a141 100644 --- a/components/CategoryModel.php +++ b/components/CategoryModel.php @@ -22,7 +22,9 @@ public function rules() ['title', 'string', 'max' => 128], ['image', 'image'], ['slug', 'match', 'pattern' => self::$SLUG_PATTERN, 'message' => Yii::t('easyii', 'Slug can contain only 0-9, a-z and "-" characters (max: 128).')], - ['slug', 'default', 'value' => null] + ['slug', 'default', 'value' => null], + ['status', 'integer'], + ['status', 'default', 'value' => self::STATUS_ON] ]; } diff --git a/modules/article/controllers/ItemsController.php b/modules/article/controllers/ItemsController.php index b6cab23..6c6f9f0 100644 --- a/modules/article/controllers/ItemsController.php +++ b/modules/article/controllers/ItemsController.php @@ -64,7 +64,6 @@ public function actionCreate($id) $model->image = ''; } } - $model->status = Item::STATUS_ON; if ($model->save()) { $this->flash('success', Yii::t('easyii/article', 'Article created')); diff --git a/modules/article/models/Item.php b/modules/article/models/Item.php index 5d14a0a..d783b1d 100644 --- a/modules/article/models/Item.php +++ b/modules/article/models/Item.php @@ -24,10 +24,11 @@ public function rules() [['title', 'short', 'text'], 'trim'], ['title', 'string', 'max' => 128], ['image', 'image'], - [['views', 'time'], 'integer'], + [['category_id', 'views', 'time', 'status'], 'integer'], ['time', 'default', 'value' => time()], ['slug', 'match', 'pattern' => self::$SLUG_PATTERN, 'message' => Yii::t('easyii', 'Slug can contain only 0-9, a-z and "-" characters (max: 128).')], ['slug', 'default', 'value' => null], + ['status', 'default', 'value' => self::STATUS_ON], ]; } diff --git a/modules/carousel/models/Carousel.php b/modules/carousel/models/Carousel.php index 6d7aee1..840cf89 100644 --- a/modules/carousel/models/Carousel.php +++ b/modules/carousel/models/Carousel.php @@ -21,6 +21,8 @@ public function rules() return [ ['image', 'image'], [['title', 'text', 'link'], 'trim'], + ['status', 'integer'], + ['status', 'default', 'value' => self::STATUS_ON], ]; } diff --git a/modules/catalog/controllers/ItemsController.php b/modules/catalog/controllers/ItemsController.php index 4d914ee..d8b9b1d 100644 --- a/modules/catalog/controllers/ItemsController.php +++ b/modules/catalog/controllers/ItemsController.php @@ -66,8 +66,6 @@ public function actionCreate($id) $model->image = ''; } } - $model->status = Item::STATUS_ON; - if ($model->save()) { $this->flash('success', Yii::t('easyii/catalog', 'Item created')); return $this->redirect(['/admin/'.$this->module->id.'/items/edit/', 'id' => $model->primaryKey]); diff --git a/modules/catalog/models/Item.php b/modules/catalog/models/Item.php index 93a414e..af12d23 100644 --- a/modules/catalog/models/Item.php +++ b/modules/catalog/models/Item.php @@ -27,10 +27,11 @@ public function rules() ['description', 'safe'], ['price', 'number'], ['discount', 'integer', 'max' => 99], - [['available', 'time'], 'integer'], + [['status', 'category_id', 'available', 'time'], 'integer'], ['time', 'default', 'value' => time()], ['slug', 'match', 'pattern' => self::$SLUG_PATTERN, 'message' => Yii::t('easyii', 'Slug can contain only 0-9, a-z and "-" characters (max: 128).')], ['slug', 'default', 'value' => null], + ['status', 'default', 'value' => self::STATUS_ON], ]; } diff --git a/modules/faq/controllers/AController.php b/modules/faq/controllers/AController.php index da25aa4..278fafa 100644 --- a/modules/faq/controllers/AController.php +++ b/modules/faq/controllers/AController.php @@ -46,8 +46,6 @@ public function actionCreate($slug = null) return ActiveForm::validate($model); } else{ - $model->status = Faq::STATUS_ON; - if($model->save()){ $this->flash('success', Yii::t('easyii/faq', 'Entry created')); return $this->redirect(['/admin/'.$this->module->id]); diff --git a/modules/faq/models/Faq.php b/modules/faq/models/Faq.php index 3b1388c..af70b42 100644 --- a/modules/faq/models/Faq.php +++ b/modules/faq/models/Faq.php @@ -22,6 +22,8 @@ public function rules() return [ [['question','answer'], 'required'], [['question', 'answer'], 'trim'], + ['status', 'integer'], + ['status', 'default', 'value' => self::STATUS_ON], ]; } diff --git a/modules/news/controllers/AController.php b/modules/news/controllers/AController.php index 3907a2c..033ae24 100644 --- a/modules/news/controllers/AController.php +++ b/modules/news/controllers/AController.php @@ -59,8 +59,6 @@ public function actionCreate() $model->image = ''; } } - $model->status = News::STATUS_ON; - if($model->save()){ $this->flash('success', Yii::t('easyii/news', 'News created')); return $this->redirect(['/admin/'.$this->module->id]); diff --git a/modules/news/models/News.php b/modules/news/models/News.php index 3933b75..ece31a2 100644 --- a/modules/news/models/News.php +++ b/modules/news/models/News.php @@ -23,10 +23,11 @@ public function rules() [['title', 'short', 'text'], 'trim'], ['title', 'string', 'max' => 128], ['image', 'image'], - [['views', 'time'], 'integer'], + [['views', 'time', 'status'], 'integer'], ['time', 'default', 'value' => time()], ['slug', 'match', 'pattern' => self::$SLUG_PATTERN, 'message' => Yii::t('easyii', 'Slug can contain only 0-9, a-z and "-" characters (max: 128).')], - ['slug', 'default', 'value' => null] + ['slug', 'default', 'value' => null], + ['status', 'default', 'value' => self::STATUS_ON], ]; }