/**
  * Creates a new Pages model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Pages();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Esempio n. 2
0
 /**
  * Creates a new Pages model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     if (!\Yii::$app->user->isGuest) {
         $model = new Pages();
         if ($model->load(Yii::$app->request->post()) && $model->save()) {
             return $this->redirect(['view', 'id' => $model->id]);
         } else {
             return $this->render('create', ['model' => $model]);
         }
     }
     $model = new LoginForm();
     if ($model->load(\Yii::$app->request->post()) && $model->login()) {
         $dataProvider = new ActiveDataProvider(['query' => Pages::find()]);
         return $this->render('index', ['dataProvider' => $dataProvider]);
     } else {
         return $this->render('login', ['model' => $model]);
     }
 }