コード例 #1
0
ファイル: GoodsController.php プロジェクト: wordnews/wei_shop
 /**
  * Deletes an existing Goods model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     if (!$this->is_access('goods/delete')) {
         Yii::$app->session->setFlash('error', $this->errorInfo);
         return $this->redirect($this->redirectUrl);
     }
     if ($this->findModel($id)->delete()) {
         // 删除相册
         GoodsGallery::deleteAll(['goods_id' => $id]);
         // 删除属性
         GoodsAttr::deleteAll(['goods_id' => $id]);
         Yii::$app->session->setFlash('success', '删除成功');
     }
     return $this->redirect(['remove']);
 }