modules/api/v1/controllers/ProductCategoryController.php
/**
     * Deletes an existing ProductCategory model.
     * If deletion is successful, the browser will be redirected to the 'index' page.
     * @param integer $id
     * @return mixed
     * @throws NotFoundHttpException if the model cannot be found
     */
Deletes an existing ProductCategory model.
If deletion is successful, the browser will be redirected to the 'index' page.
@param integer $id
@return mixed
@throws NotFoundHttpException if the model cannot be found
Deletes an existing ProductCategory model . If deletion is successful the browser will be redirected to the ' index ' page . @param integer $id @return mixed @throws NotFoundHttpException if the model cannot be found
public function actionDelete($id)
    {
        $model = ProductCategory::findOne($id);
        if (!$model instanceof ProductCategory) {
            throw new NotFoundHttpException('Product category doesn\'t exist.');
        }
        if (!empty($model) && !empty($model->image)) {
            $uploadDirPath = Yii::getAlias('@productCategoryImageRelativePath');
            $uploadThumbDirPath = Yii::getAlias('@productCategoryImageThumbRelativePath');
            if (file_exists($uploadDirPath . '/' . $model->image)) {
                unlink($uploadDirPath . '/' . $model->image);
            }
            if (file_exists($uploadThumbDirPath . '/' . $model->image)) {
                unlink($uploadThumbDirPath . '/' . $model->image);
            }
        }
        $model->delete();
    }
public function actionDelete ( $ id ) { $ model = ProductCategory :: findOne ( $ id ) ; if ( ! $ model instanceof ProductCategory ) { throw new NotFoundHttpException ( 'Product category doesn\'t exist.' ) ; } if ( ! empty ( $ model ) && ! empty ( $ model -> image ) ) { $ uploadDirPath = Yii :: getAlias ( '@productCategoryImageRelativePath' ) ; $ uploadThumbDirPath = Yii :: getAlias ( '@productCategoryImageThumbRelativePath' ) ; if ( file_exists ( $ uploadDirPath . '/' . $ model -> image ) ) { unlink ( $ uploadDirPath . '/' . $ model -> image ) ; } if ( file_exists ( $ uploadThumbDirPath . '/' . $ model -> image ) ) { unlink ( $ uploadThumbDirPath . '/' . $ model -> image ) ; } } $ model -> delete ( ) ; }
Deletes an existing ProductCategory model.
Deletes an existing ProductCategory model .
//unlink real image if update //unlink thumb image if update