backend/modules/cms/controllers/BannerController.php
/**
     * Updates an existing Banner model.
     * If update is successful, the browser will be redirected to the 'view' page.
     * @param integer $id
     * @return mixed
     */
Updates an existing Banner model.
If update is successful, the browser will be redirected to the 'view' page.
@param integer $id
@return mixed
Updates an existing Banner model . If update is successful the browser will be redirected to the ' view ' page . @param integer $id @return mixed
public function actionUpdate($id) {
        $model = $this->findModel($id);
        $banner_ = $model->banner;
        $banner_ar_ = $model->banner_ar;
        if ($id == 1) {
            $width = 867;
            $height = 369;
        } else if ($id == 2) {
            $width = 518;
            $height = 369;
        } else if ($id == 3) {
            $width = 873;
            $height = 264;
        } else if ($id == 4) {
            $width = 1374;
            $height = 266;
        }
        if ($model->load(Yii::$app->request->post())) {
            $banner = UploadedFile::getInstance($model, 'banner');
            if (!empty($banner))
                $model->banner = $banner->extension;
            else
                $model->banner = $banner_;
            $banner_ar = UploadedFile::getInstance($model, 'banner_ar');
            if (!empty($banner_ar))
                $model->banner_ar = $banner_ar->extension;
            else
                $model->banner_ar = $banner_ar_;
            if ($model->save()) {
                if (!empty($banner)) {
                    $path = Yii::$app->basePath . '/../uploads/cms/banner/' . $model->id . '/en/';
                    $size = [
                        ['width' => 100, 'height' => 100, 'name' => 'small'],
                        ['width' => $width, 'height' => $height, 'name' => 'image'],
                    ];
                    Yii::$app->UploadFile->UploadFile($model, $banner, $path, $size);
                }
                if (!empty($banner_ar)) {
                    $path1 = Yii::$app->basePath . '/../uploads/cms/banner/' . $model->id . '/ar/';
                    $size = [
                        ['width' => 100, 'height' => 100, 'name' => 'small'],
                        ['width' => $width, 'height' => $height, 'name' => 'image'],
                    ];
                    Yii::$app->UploadFile->UploadFile($model, $banner_ar, $path1, $size);
                }
                Yii::$app->session->setFlash('success', "Updated Successfully");
                return $this->redirect(['index']);
            }
        }
        return $this->render('update', [
                    'model' => $model,
                    'width' => $width,
                    'height' => $height
        ]);
    }
public function actionUpdate ( $ id ) { $ model = $ this -> findModel ( $ id ) ; $ banner_ = $ model -> banner ; $ banner_ar_ = $ model -> banner_ar ; if ( $ id == 1 ) { $ width = 867 ; $ height = 369 ; } else if ( $ id == 2 ) { $ width = 518 ; $ height = 369 ; } else if ( $ id == 3 ) { $ width = 873 ; $ height = 264 ; } else if ( $ id == 4 ) { $ width = 1374 ; $ height = 266 ; } if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) ) { $ banner = UploadedFile :: getInstance ( $ model , 'banner' ) ; if ( ! empty ( $ banner ) ) $ model -> banner = $ banner -> extension ; else $ model -> banner = $ banner_ ; $ banner_ar = UploadedFile :: getInstance ( $ model , 'banner_ar' ) ; if ( ! empty ( $ banner_ar ) ) $ model -> banner_ar = $ banner_ar -> extension ; else $ model -> banner_ar = $ banner_ar_ ; if ( $ model -> save ( ) ) { if ( ! empty ( $ banner ) ) { $ path = Yii :: $ app -> basePath . '/../uploads/cms/banner/' . $ model -> id . '/en/' ; $ size = [ [ 'width' => 100 , 'height' => 100 , 'name' => 'small' ] , [ 'width' => $ width , 'height' => $ height , 'name' => 'image' ] , ] ; Yii :: $ app -> UploadFile -> UploadFile ( $ model , $ banner , $ path , $ size ) ; } if ( ! empty ( $ banner_ar ) ) { $ path1 = Yii :: $ app -> basePath . '/../uploads/cms/banner/' . $ model -> id . '/ar/' ; $ size = [ [ 'width' => 100 , 'height' => 100 , 'name' => 'small' ] , [ 'width' => $ width , 'height' => $ height , 'name' => 'image' ] , ] ; Yii :: $ app -> UploadFile -> UploadFile ( $ model , $ banner_ar , $ path1 , $ size ) ; } Yii :: $ app -> session -> setFlash ( 'success' , " Updated Successfully " ) ; return $ this -> redirect ( [ 'index' ] ) ; } } return $ this -> render ( 'update' , [ 'model' => $ model , 'width' => $ width , 'height' => $ height ] ) ; }
Updates an existing Banner model.
Updates an existing Banner model .