コード例 #1
0
ファイル: BooksController.php プロジェクト: akomyagin/books
 /**
  * Creates a new Books model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Books();
     if ($model->load(Yii::$app->request->post())) {
         $model->uploadImage();
         return $model->save() ? $this->redirect(['index']) : var_dump($model);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
コード例 #2
0
ファイル: BooksController.php プロジェクト: verve000/verve000
 public function actionCreate()
 {
     $model = new Books();
     if ($model->load(Yii::$app->request->post())) {
         $model->uploadImage();
         $model->date_create = date('Y-m-d');
         $model->date_update = date('Y-m-d');
         $model->save();
         return $this->redirect(['index']);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
コード例 #3
0
 /**
  * Creates a new Books model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Books();
     if ($model->load(Yii::$app->request->post())) {
         $image = $model->uploadImage();
         if ($image !== false) {
             $path = $model->getImageFile();
             $image->saveAs($path);
         }
         //                if ($path = $model->upload()) {
         //                    $model->preview_image = $path;
         //                }
         $model->save();
         return $this->redirect(['index']);
     } else {
         return $this->render('create', ['model' => $model, 'authors' => Authors::getAuthorsList()]);
     }
 }