POST delete method that accepts data via JSON POST and either saves an old.

@param string $modelName
@param int    $id

@return JSON
335259
public function delete($modelName, $id)
    {
        $config        = app('itemconfig');
        $actionFactory = app('admin_action_factory');
        $baseModel     = $config->getDataModel();
        $model         = $baseModel::find($id);
        $errorResponse = array(
            'success' => false,
            'error'   => 'There was an error deleting this item. Please reload the page and try again.',
        );

        //if the model or the id don't exist, send back an error
        $permissions = $actionFactory->getActionPermissions();

        if (!$model->exists || !$permissions['delete']) {
            return response()->json($errorResponse);
        }

        //delete the model
        // 如果删除成功，或者数据库里面再也找不到了，就算成功
        if ($model->delete() || !$baseModel::find($id)) {
            return response()->json(array(
                'success' => true,
            ));
        } else {
            return response()->json($errorResponse);
        }
    }
1285191
public function getDelete($id = null)
    {
        // Get comment information
        $comment = Comments::getCommentsRepository()->find($id);

        if ($comment == null)
        {
            // Prepare the error message
            $error = Lang::get('comments.comment.not_found');

            // Redirect to the post management page
            return Redirect::route('posts')->with('error', $error);
        }

        Base::Log('Comment (' . $comment->id . ') was deleted.');

        // Delete the post
        $comment->delete();

        // Prepare the success message
        $success = Lang::get('comments.comment.deleted');

        // Redirect to the post management page
        return Redirect::back()->with('success', $success);
    }
780886
public function deleteAction($entity, $id)
    {
        $em = $this->getDoctrine()->getManager();
        $entity = $em->getRepository($entity)->find($id);

        if (!$entity) {
            throw $this->createNotFoundException("Unable to find $entity entity.");
        }

        $em->remove($entity);
        $em->flush();

        $this->get('session')->getFlashBag()->add(
                'success', 'The Post has been removed.');

        $content = json_encode(array(
            'status' => 'deleted',
        ));

        $response = new Response($content, 200);

        return $response;
    }
917139
public function delete($id)
    {
        $id = (int)$id;
        $siteId = $this->getRequestSiteId();

        //ACCESS CHECK
        $sitePagesResource = $this->getSitePagesResourceId($siteId);
        if (!$this->isAllowed('pages', 'delete')
            && !$this->isAllowed(
                $sitePagesResource,
                'delete'
            )
        ) {
            $this->getResponse()->setStatusCode(Response::STATUS_CODE_401);

            return new ApiJsonModel(
                null,
                1,
                "Access denied"
            );
        }

        $site = $this->getSite($siteId);

        if (empty($site)) {
            return new ApiJsonModel(
                null,
                1,
                "Site was not found with id {$siteId}."
            );
        }

        $page = $this->getPage($site, $id);

        if (empty($page)) {
            return new ApiJsonModel(
                null,
                404,
                "Page was not found with id {$id}."
            );
        }

        $this->pageMutationService->depublishPage($this->getCurrentUser(), $page);

        return new ApiJsonModel([true], 0, 'Page deleted');
    }
1023142
public function actionDelete($id)
    {
        $this->findModel($id)->updateAttributes(['status' => User::STATUS_DELETED]);

        return $this->redirect(['index']);
    }
336725
public function delete($id = null)
    {
        $this->request->allowMethod(['post', 'delete']);

        $this->Posts->deleteOrFail($this->Posts->get($id));
        $this->Flash->success(I18N_OPERATION_OK);

        return $this->redirect(['action' => 'index']);
    }
203441
public function actionDelete($id)
    {
        $this->findModel($id)->delete();
        Helper::invalidate();

        return $this->redirect(['index']);
    }
1079418
public function deleteAction(Request $request, $id)
    {
        $entity = $this->getRepository()->find($id);

        if (!$entity) {
            throw $this->createNotFoundException('Unable to find ' . $this->getEntityName() . '.');
        }

        $em = $this->getDoctrine()->getManager();

        $this->get('session')->getFlashBag()->add('success', ucfirst($this->getEntityName()) . ' has been deleted!');

        $em->remove($entity);
        $em->flush();

        if ($request->getMethod() == "DELETE") {
            return new JsonResponse([
                'success' => true
            ]);
        } else {
            return $this->redirect($this->getRefererUrl());
        }
    }
1253728
public function delete($id = null)
    {
        $this->request->allowMethod(['post', 'delete']);
        $cmsTerm = $this->CmsTerm->get($id);
        if ($this->CmsTerm->delete($cmsTerm)) {
            $this->Flash->success('The cms term has been deleted.');
        } else {
            $this->Flash->error('The cms term could not be deleted. Please, try again.');
        }
        return $this->redirect(['action' => 'index']);
    }
827603
public function actionDelete($id)
    {
        $model = $this->findModel($id);
        $model->delete();

        return $this->redirect(['index']);
    }
943656
public function delete($model, $id) {
		$runtime = $this->runtime[$model->alias];

		$data = array();
		$fields = $this->_normalizeFields($model);
		foreach ($fields as $flag => $date) {
			if (true === $runtime || $flag === $runtime) {
				$data[$flag] = true;
				if ($date) {
					$data[$date] = date('Y-m-d H:i:s');
				}
				if ($flag === $runtime) {
					break;
				}
			}
		}

		$record = $model->find('first', array(
			'fields' => $model->primaryKey,
			'conditions' => array($model->primaryKey => $id),
			'recursive' => -1
		));

		if (!empty($record)) {
			$model->set($model->primaryKey, $id);
			unset($model->data[$model->alias]['modified']);
			unset($model->data[$model->alias]['updated']);
			return $model->save(array($model->alias => $data), false, array_keys($data));
		}

		return true;
	}
723454
public function actionDelete($id)
    {
        $commentModel = $this->findModel($id);
        $commentModel->setScenario(CommentModel::SCENARIO_MODERATION);
        $event = Yii::createObject(['class' => CommentEvent::class, 'commentModel' => $commentModel]);
        $this->trigger(self::EVENT_BEFORE_DELETE, $event);

        if ($commentModel->markRejected()) {
            $this->trigger(self::EVENT_AFTER_DELETE, $event);

            return Yii::t('yii2mod.comments', 'Comment has been deleted.');
        } else {
            Yii::$app->response->setStatusCode(500);

            return Yii::t('yii2mod.comments', 'Comment has not been deleted. Please try again!');
        }
    }
30402
public function actionDelete($id)
	{
		//$this->loadModel($id)->delete();

		// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
		//if(!isset($_GET['ajax']))
		//	$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
                
                
                
                $model = $this->loadModel($id);
				
		$sql = 'ALTER TABLE '.BaseCccdCompanyData::model()->tableName().' DROP `'.$model->varname.'`';
				if ($model->dbConnection->createCommand($sql)->execute()) {
					$model->delete();
				}
			

		// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
		if(!isset($_POST['ajax']))
				$this->redirect(array('admin'));
		
		else
			throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');
	

	}
302652
public function destroy($id, Request $request)
    {
        $model = $this->model();

        $force = false;
        if (method_exists($model, 'forceDelete')) {
            $this->validate($request, ['force' => ['boolean']]);

            $model = $model->withTrashed();
            $force = (bool) $request->input('force');
        }

        return $this->deleteModel($model->find($id), 'delete', $force);
    }
1318783
public function actionDelete($id)
    {
        $this->findModel($id)->delete();
        if (Yii::$app->request->getIsAjax()) {
            \Yii::$app->response->format = 'json';
            return ['success' => true];
        } else {
            return $this->redirect(['index']);
        }
    }
416693
protected static function doDelete($id)
    {
        $model = self::createModelInstance();
        $tableName = $model->getTableName($model->className);

        $connection = Connection::connect();

        $delete = $connection->prepare('delete from '.$tableName.' where id ='.$id);
        return $delete->execute() ? 'deleted successfully' : 'Row not deleted';

         
    }
451088
public function delete($id)
	{
		$this->getResponse()
			->setStatusCode(Response::STATUS_CODE_200);
		
		$request = $this->getRequest();
		$content = $request->getContent();
		$content = !empty($content) ? Json::decode($content, Json::TYPE_ARRAY) : array();
		$post = array_merge_recursive(
			$request->getPost()->toArray(),
			$content
		);
		$classifiedService = $this->getServiceLocator()->get('document.service.classified');

		$returnData = '';
		$action = strtolower($id);
		$classifiedService = $this->getServiceLocator()->get('document.service.classified');
		
		switch($action) {
			case 'bulk':
				$ids = $this->params()->fromQuery('ids', array());
				$ids = !is_array($ids) ? explode(",", $ids) : $ids;
				$success = 0;
				$error = 0;
				foreach($ids as $id) {
					try {
						$classifiedService->delete($id);		
						$success++;
					} catch(\Exception $e) {
						$error++;
					};
				}
						
				$returnData = array(
					'status' => 'success',
					'message' => 'Annunci eliminati con successo (' . $success . '/' . $error . ')'
				);
				break;
			default:
				try {
					$classifiedService->delete($id);
					$returnData = array(
						'status' => 'success',
						'message' => 'Annuncio eliminato con successo'
					);
				} catch(\Exception $e) {
					$this->getResponse()
					->setStatusCode(Response::STATUS_CODE_500);
					$returnData = array(
						'status' => 'danger',
						'message' => $e->getMessage()
					);
				}
				break;
		}

		return new JsonModel($returnData);
	}