modules/api/v1/controllers/ProductCategoryController.php
/**
     * Updates an existing ProductCategory 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 ProductCategory 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 ProductCategory 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 = ProductCategory::findOne($id);
        if (!$model instanceof ProductCategory) {
            throw new NotFoundHttpException('Product category doesn\'t exist.');
        }
        $postData = Yii::$app->request->post();
        $productCategoryData['ProductCategory'] = $postData;
        if ($model->load($productCategoryData) && $model->validate()) {
            $model->save();
        }
        if (!empty($model->image) && file_exists(Yii::getAlias('@productCategoryImageThumbRelativePath') . '/' . $model->image)) {
            $model->image = Yii::$app->request->getHostInfo() . Yii::getAlias('@productCategoryImageThumbAbsolutePath') . '/' . $model->image;
        } else {
            $model->image = Yii::$app->request->getHostInfo() . Yii::getAlias('@uploadsAbsolutePath') . '/no-image.jpg';
        }
        return $model;
    }
public function actionUpdate ( $ id ) { $ model = ProductCategory :: findOne ( $ id ) ; if ( ! $ model instanceof ProductCategory ) { throw new NotFoundHttpException ( 'Product category doesn\'t exist.' ) ; } $ postData = Yii :: $ app -> request -> post ( ) ; $ productCategoryData [ 'ProductCategory' ] = $ postData ; if ( $ model -> load ( $ productCategoryData ) && $ model -> validate ( ) ) { $ model -> save ( ) ; } if ( ! empty ( $ model -> image ) && file_exists ( Yii :: getAlias ( '@productCategoryImageThumbRelativePath' ) . '/' . $ model -> image ) ) { $ model -> image = Yii :: $ app -> request -> getHostInfo ( ) . Yii :: getAlias ( '@productCategoryImageThumbAbsolutePath' ) . '/' . $ model -> image ; } else { $ model -> image = Yii :: $ app -> request -> getHostInfo ( ) . Yii :: getAlias ( '@uploadsAbsolutePath' ) . '/no-image.jpg' ; } return $ model ; }
Updates an existing ProductCategory model.
Updates an existing ProductCategory model .
// $model->scenario = ProductCategory::SCENARIO_CREATE;