/** * Creates a new Banner model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Banner(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->banner_id]); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new Banner model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Banner(); if ($model->load(Yii::$app->request->post())) { $model->file = UploadedFile::getInstance($model, 'file'); $model->file_name = 'banners/' . $model->file->baseName . '.' . $model->file->extension; if ($model->save()) { return $this->redirect(['index']); } } return $this->render('create', ['model' => $model]); }
/** * Creates a new Banner model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Banner(); if ($model->load(Yii::$app->request->post())) { $resourceModel = new Resource(); $model = $resourceModel->uploadImg($model, 'img'); if ($model->save()) { return $this->redirect(['index']); } } return $this->render('create', ['model' => $model]); }
/** * Creates a new Banner model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Banner(); if ($model->load(Yii::$app->request->post()) && $model->save()) { foreach (Property::getLanguages() as $lang) { $file = UploadedFile::getInstanceByName('image_' . $lang); if (!is_null($file)) { ImageManager::addBannerImage($model->id, $file, $lang); } } return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new Banner model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $this->layout = 'admin'; $model = new Banner(); if ($model->load(Yii::$app->request->post())) { $file = UploadedFile::getInstance($model, 'banner_img'); if ($file->size != 0) { $model->filename = $file->name; $file->saveAs('uploads/banner/' . $file->name); $model->save(); } return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }