Пример #1
0
 public function actionDelete($id)
 {
     $output = ['status' => 'fail', 'data' => []];
     $model = CartGoods::findOne(['goods_id' => $id, 'user_id' => Yii::$app->user->id]);
     if ($model) {
         if (!$model->delete()) {
             return $output;
         }
     }
     $output['status'] = 'success';
     return $output;
 }
Пример #2
0
 public function actionDelete()
 {
     $goodsId = (int) Yii::$app->request->post('goodsId');
     $output = ['status' => 'no'];
     Yii::$app->response->format = Response::FORMAT_JSON;
     $model = CartGoods::findOne(['goods_id' => $goodsId, 'user_id' => Yii::$app->user->id]);
     if ($model) {
         if (!$model->delete()) {
             return $output;
         }
     }
     $output['status'] = 'ok';
     return $output;
 }