示例#1
0
 /**
  * Create form
  *
  * @param null $parent
  * @return array|string|\yii\web\Response
  * @throws \yii\web\HttpException
  */
 public function actionCreate($parent = null)
 {
     return;
     $class = $this->categoryClass;
     $model = new $class();
     if ($model->load(Yii::$app->request->post())) {
         if (Yii::$app->request->isAjax) {
             Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
             return ActiveForm::validate($model);
         } else {
             if (isset($_FILES) && $this->module->settings['categoryThumb']) {
                 $model->image = UploadedFile::getInstance($model, 'image');
                 if ($model->image && $model->validate(['image'])) {
                     $model->image = Image::upload($model->image, $this->moduleName);
                 } else {
                     $model->image = '';
                 }
             }
             $model->status = $class::STATUS_ON;
             $parent = (int) Yii::$app->request->post('parent', null);
             if ($parent > 0 && ($parentCategory = $class::findOne($parent))) {
                 $model->order_num = $parentCategory->order_num;
                 $model->appendTo($parentCategory);
             } else {
                 $model->attachBehavior('sortable', SortableModel::className());
                 $model->makeRoot();
             }
             if (!$model->hasErrors()) {
                 $this->flash('success', Yii::t('easyii', 'Category created'));
                 return $this->redirect(['/admin/' . $this->moduleName, 'id' => $model->primaryKey]);
             } else {
                 $this->flash('error', Yii::t('easyii', 'Create error. {0}', $model->formatErrors()));
                 return $this->refresh();
             }
         }
     } else {
         return $this->render('@easyii/views/category/create', ['model' => $model, 'parent' => $parent]);
     }
 }
示例#2
0
 /**
  * @return array
  */
 public function behaviors()
 {
     return ['sortable' => SortableModel::className(), 'mlBehavior' => ['class' => MultiLanguageBehavior::className(), 'mlConfig' => ['db_table' => 'translations_with_string', 'attributes' => ['label'], 'admin_routes' => ['admin/*']]]];
 }
示例#3
0
 public function behaviors()
 {
     return [SortableModel::className(), 'seoBehavior' => SeoBehavior::className(), 'sluggable' => ['class' => SluggableBehavior::className(), 'attribute' => 'title', 'ensureUnique' => true]];
 }
示例#4
0
 public function behaviors()
 {
     return [CacheFlush::className(), SortableModel::className()];
 }
示例#5
0
文件: Item.php 项目: radiegtya/easyii
 public function behaviors()
 {
     return [SortableModel::className(), 'seo' => SeoBehavior::className(), 'sluggable' => ['class' => SluggableBehavior::className(), 'attribute' => 'title', 'ensureUnique' => true], 'blameable' => ['class' => BlameableBehavior::className(), 'createdByAttribute' => 'created_by', 'updatedByAttribute' => 'updated_by']];
 }
示例#6
0
 public function behaviors()
 {
     return array_merge_recursive(parent::behaviors(), [CacheFlush::className(), SortableModel::className()]);
 }
示例#7
0
 public function behaviors()
 {
     return [SortableModel::className()];
 }
示例#8
0
文件: File.php 项目: kuzmiand/easyii
 public function behaviors()
 {
     return [SortableModel::className(), 'seoBehavior' => SeoBehavior::className(), 'sluggable' => ['class' => SluggableBehavior::className(), 'attribute' => 'title', 'ensureUnique' => true], 'mlBehavior' => ['class' => MultiLanguageBehavior::className(), 'mlConfig' => ['db_table' => 'translations_with_string', 'attributes' => ['title', 'file', 'image'], 'admin_routes' => ['admin/*']]]];
 }
示例#9
0
 public function behaviors()
 {
     return [CacheFlush::className(), SortableModel::className(), 'mlBehavior' => ['class' => MultiLanguageBehavior::className(), 'mlConfig' => ['db_table' => 'translations_with_string', 'attributes' => ['title', 'short', 'text'], 'admin_routes' => ['admin/*']]]];
 }
示例#10
0
文件: Item.php 项目: radiegtya/easyii
 public function behaviors()
 {
     return [SortableModel::className(), 'seo' => SeoBehavior::className(), 'sluggable' => ['class' => SluggableBehavior::className(), 'attribute' => 'title', 'ensureUnique' => true], 'blameable' => ['class' => BlameableBehavior::className(), 'createdByAttribute' => 'created_by', 'updatedByAttribute' => 'updated_by'], 'timestamp' => ['class' => TimestampBehavior::className(), 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'], ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at']], 'value' => new Expression('NOW()')]];
 }