public function actionDelete($id) { $idList = explode(',', $id); foreach ($idList as &$perId) { $perId = new \MongoId($perId); $card = MemberShipCard::findByPk($perId); if ($card->isDefault) { throw new BadRequestHttpException(\Yii::t('member', 'delete_default_card_error')); } $provideCount = Member::getCountByCardId($perId); if ($provideCount > 0) { throw new BadRequestHttpException(\Yii::t('member', 'delete_member_exist_card_error')); } } $modelClass = $this->modelClass; if ($modelClass::deleteAll(['in', '_id', $idList]) == false) { throw new ServerErrorHttpException('Failed to delete the object for unknown reason.'); } Yii::$app->getResponse()->setStatusCode(204); }