Exemplo n.º 1
0
 /** Создание нового раздела
  */
 public function actionCreate($cat_id = 0)
 {
     $model = new Categories();
     $model->attachBehavior('createStoreDir', ['class' => StoreDirBehavior::className(), 'handlerName' => 'gallery']);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect([$model->handler . '/list', 'id' => $model->id]);
     } else {
         $model->parent_id = $cat_id;
         return $this->render('create', ['model' => $model]);
     }
 }
Exemplo n.º 2
0
 /**
  * Не разрешаем изменять свойства
  */
 public function actionUpdate($id)
 {
     $model = $this->findAlbum($id);
     if ($model->isEmpty) {
         return $this->redirect(['album/list', 'id' => $model->parent_id]);
     }
     $model->attachBehavior('changeStoreDir', ['class' => StoreDirBehavior::className(), 'handlerName' => $this->id]);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['image/list', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model]);
     }
 }
Exemplo n.º 3
0
 public function actionNewAlbum($id)
 {
     if ($id == 0) {
         throw new BadRequestHttpException("Неправильный запрос");
     }
     $model = new Resources(['scenario' => 'album']);
     $model->category_id = $id;
     $model->attachBehavior('createStoreDir', ['class' => StoreDirBehavior::className(), 'handlerName' => $this->id]);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['list', 'id' => $model->id]);
     } else {
         return $this->render('new-album', ['model' => $model]);
     }
 }
Exemplo n.º 4
0
 /**
  * Creates a new Resources model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($id)
 {
     if ($id == 0) {
         throw new \yii\web\BadRequestHttpException("Неправильный запрос");
     }
     $model = new Categories();
     $model->parent_id = $id;
     $model->handler = $this->id;
     $model->attachBehavior('createStoreDir', ['class' => StoreDirBehavior::className(), 'handlerName' => $this->id]);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['list', 'id' => $model->parent_id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }