modules/api/v2/controllers/BrandController.php
/**
     * Updates an existing Brand model.
     * If update is successful, the browser will be redirected to the 'view' page.
     * @param integer $id
     * @return mixed
     * @throws NotFoundHttpException if the model cannot be found
     */
Updates an existing Brand model.
If update is successful, the browser will be redirected to the 'view' page.
@param integer $id
@return mixed
@throws NotFoundHttpException if the model cannot be found
Updates an existing Brand model . If update is successful the browser will be redirected to the ' view ' page . @param integer $id @return mixed @throws NotFoundHttpException if the model cannot be found
public function actionUpdate($id)
    {
        $model = Brand::findOne($id);
        if (!$model instanceof Brand) {
            throw new NotFoundHttpException('Brand doesn\'t exist.');
        }
        $postData = \Yii::$app->request->post();
        $brandData['Brand'] = $postData;
        if ($model->load($brandData) && $model->validate()) {
            if ($model->save(false)) {
                $brandImage = Yii::$app->request->getHostInfo() . Yii::getAlias('@uploadsAbsolutePath') . '/no-image.jpg';
                if (!empty($model->image) && file_exists(Yii::getAlias('@brandImageThumbRelativePath') . '/' . $model->image)) {
                    $brandImage = Yii::$app->request->getHostInfo() . Yii::getAlias('@brandImageThumbAbsolutePath') . '/' . $model->image;
                }
                $model->image = $brandImage;
            }
        }
        return $model;
    }
public function actionUpdate ( $ id ) { $ model = Brand :: findOne ( $ id ) ; if ( ! $ model instanceof Brand ) { throw new NotFoundHttpException ( 'Brand doesn\'t exist.' ) ; } $ postData = \ Yii :: $ app -> request -> post ( ) ; $ brandData [ 'Brand' ] = $ postData ; if ( $ model -> load ( $ brandData ) && $ model -> validate ( ) ) { if ( $ model -> save ( false ) ) { $ brandImage = Yii :: $ app -> request -> getHostInfo ( ) . Yii :: getAlias ( '@uploadsAbsolutePath' ) . '/no-image.jpg' ; if ( ! empty ( $ model -> image ) && file_exists ( Yii :: getAlias ( '@brandImageThumbRelativePath' ) . '/' . $ model -> image ) ) { $ brandImage = Yii :: $ app -> request -> getHostInfo ( ) . Yii :: getAlias ( '@brandImageThumbAbsolutePath' ) . '/' . $ model -> image ; } $ model -> image = $ brandImage ; } } return $ model ; }
Updates an existing Brand model.
Updates an existing Brand model .