Пример #1
0
 /**
  * Creates a new Resources model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Resources();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Пример #2
0
 /**
  *   Создание новой страницы в категории $id.
  */
 public function actionCreate($id)
 {
     $model = new Resources();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['list', 'id' => $id]);
     } else {
         $model->category_id = $id;
         return $this->render('create', ['model' => $model]);
     }
 }
Пример #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]);
     }
 }