/**
  * Creates a new Section model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $section = new Section();
     $section_ru = new Section_ru();
     $section_en = new Section_en();
     if ($section->load(Yii::$app->request->post())) {
         $images = UploadedFile::getInstances($section, 'images');
         $newFileName = date("YmdHis");
         $filePath = Yii::getAlias('@frontend') . '/web/uploads/' . $newFileName . '.' . $images[0]->extension;
         $file427320 = Yii::getAlias('@frontend') . '/web/uploads/427320/' . $newFileName . '.' . $images[0]->extension;
         $images[0]->saveAs($filePath);
         Image::thumbnail($filePath, 427, 320)->save($file427320, ['quality' => 50]);
         $section->photo_path = Yii::getAlias('@resource') . '/uploads/' . $newFileName . '.' . $images[0]->extension;
         $section->photo_path427320 = Yii::getAlias('@resource') . '/uploads/427320/' . $newFileName . '.' . $images[0]->extension;
     }
     if ($section->load(Yii::$app->request->post()) && $section_ru->load(Yii::$app->request->post()) && $section_en->load(Yii::$app->request->post()) && $section->save()) {
         $section_ru->section_id = $section->id;
         $section_en->section_id = $section->id;
         $section_ru->save();
         $section_en->save();
         return $this->redirect(['update', 'id' => $section->id]);
     } else {
         return $this->render('create', ['section' => $section, 'section_ru' => $section_ru, 'section_en' => $section_en]);
     }
 }
Пример #2
0
 /**
  * Creates a new Section model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Section();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }