Удаление комментариев.

@param Request $request
@param CommentsModerateServiceContract $moderateService

@return DestroyResponseContract
432198
public function destroy(Request $request, CommentsModerateServiceContract $moderateService): DestroyResponseContract
    {
        $ids = $request->get('comments') ?? [];

        $result = $moderateService->destroy($ids);

        return app()->makeWith(DestroyResponseContract::class, compact('result'));
    }
904584
public function deleteContentTypesAction(Request $request)
    {
        $format = $request->get('_format', 'json');

        $facade = $this->get('jms_serializer')->deserialize(
            $request->getContent(),
            $this->getParameter('open_orchestra_api.facade.content_type_collection.class'),
            $format
        );
        $contentTypeRepository = $this->get('open_orchestra_model.repository.content_type');
        $contentTypes = $this->get('open_orchestra_api.transformer_manager')->reverseTransform('content_type_collection', $facade);
        $contentTypeIds = array();
        foreach ($contentTypes as $contentType) {
            if ($this->isGranted(ContributionActionInterface::DELETE, $contentType) &&
                $this->get('open_orchestra_backoffice.business_rules_manager')->isGranted(BusinessActionInterface::DELETE, $contentType)
            ) {
                $contentTypeIds[] = $contentType->getContentTypeId();
                $this->dispatchEvent(ContentTypeEvents::CONTENT_TYPE_DELETE, new ContentTypeEvent($contentType));
            }
        }
        $contentTypeRepository->removeByContentTypeId($contentTypeIds);

        return array();
    }
518806
public function commentModerationAction($commentId, $hash, $status)
    {
        $action = $this->container->get(ModerateCommentAction::class);

        return $action($commentId, $hash, $status);
    }
510277
public function destroy(CommentsServiceContract $commentsService, int $id = 0): DestroyResponseContract
    {
        $result = $commentsService->destroy($id);

        return app()->makeWith(DestroyResponseContract::class, [
            'result' => (!! $result),
        ]);
    }
456301
public function destroy(Request $request, $id)
    {
        $node = Menu::where('id', $id)->first();
        $node->delete();

        return $this->response()->noContent();
    }
975139
public function destroy(Request $request, $id)
    {
        $tag = Tag::where(['id' => $id, 'user_id' => $request->user()->id])->firstOrFail();

        // Detach all tags from the did
        $tag->dids()->detach();

        $tag->delete();
    }
198582
public function deleteContentsAction(Request $request)
    {
        $format = $request->get('_format', 'json');
        $facade = $this->get('jms_serializer')->deserialize(
            $request->getContent(),
            $this->getParameter('open_orchestra_api.facade.content_collection.class'),
            $format
        );
        $contents = $this->get('open_orchestra_api.transformer_manager')->reverseTransform('content_collection', $facade);
        $repository = $this->get('open_orchestra_model.repository.content');

        foreach ($contents as $content) {
            $this->denyAccessUnlessGranted(ContributionActionInterface::DELETE, $content);
            $contentId = $content->getContentId();
            if (
                $this->get('open_orchestra_backoffice.business_rules_manager')->isGranted(BusinessActionInterface::DELETE, $content) &&
                $this->isGranted(ContributionActionInterface::DELETE, $content)
            ) {
                $repository->softDeleteContent($contentId);
                $this->dispatchEvent(ContentEvents::CONTENT_DELETE, new ContentDeleteEvent($contentId, $content->getSiteId()));
            }
        }

        return array();
    }
917313
public function destroy(NewsCategory $category, Request $request)
	{
		$this->deleteEntry($category, $request);

        return redirect_to_resource();
	}
65931
public function deleteAction(Request $request)
    {
        $id = $request->get('id');

        $elementtypeService = $this->get('phlexible_elementtype.elementtype_service');
        $elementtype = $elementtypeService->findElementtype($id);

        $elementtypeService->deleteElementtype($elementtype);

        return new ResultResponse(true, "Element type $id soft deleted.");
    }
931583
public function commentPermalink(Request $request, CommentInterface $comment) {
    if ($entity = $comment->getCommentedEntity()) {
      // Check access permissions for the entity.
      /* @var \Drupal\Core\Entity\Entity $entity */
      if (!$entity->access('view')) {
        throw new AccessDeniedHttpException();
      }
      /* @var \Drupal\Core\Url $url */
      if ($url = $entity->urlInfo('canonical')) {
        // Redirect the user to the correct entity.
        return $this->redirectToOriginalEntity($url, $comment, $entity);
      }
    }
    throw new NotFoundHttpException();
  }
861266
protected function destroyElement(Request $request, $id)
    {
        if ($data = $this->config->getModel()::find($id)) {
            if (method_exists($data, 'clearMediaCollection')) {
                $data->clearMediaCollection();
            }
            $name = $data->title;

            if ($data->delete()) {
                event(new ComponentItemDestroyed($this->config, $data, $request));
                \Cache::flush();
                Session::push('message.success', Lang::get('larrock::apps.delete.success', ['name' => $name]));
            } else {
                Session::push('message.danger', Lang::get('larrock::apps.delete.error', ['name' => $name]));
            }
        } else {
            Session::push('message.danger', 'Такого материала уже не существует');
        }
    }
404848
public function removeAction(Request $request)
    {
        $row = $this->findRowByRequest($request);
        $container = $row->getContainer();

        try {
            $this->getEditor()->getRowManager()->delete($row);
        } catch (EditorExceptionInterface $e) {
            return $this->handleException($e);
        }

        // Stores id for front removal
        $removedId = $this->getViewBuilder()->buildRow($row)->getAttributes()->getId();

        $this->validate($container);
        $this->persist($container);

        $data = [
            'removed' => [$removedId],
            //'containers' => [$this->getViewBuilder()->buildContainer($container)],
        ];

        return $this->buildResponse($data, self::SERIALIZE_LAYOUT);
    }
236507
public function crudEdit(Request $request, $id)
    {
        try{
            $entity = $this->throwEntityNotFoundException($this->getRepository()->find($id));
            $form = $this->createForm( $this->getEntityType() , $entity)->createView();
            $delete_form = $this->createDeleteForm($id)->createView();
            
            return $this->commonsResponseVars(compact('entity','form','delete_form'));
            
        }catch(\Exception $e){
          return $this->failure($e);
        }
    }
122612
public function deleteComment()
    {
        $userIsAllowed = $this
            ->userCredentialsProvider
            ->isAllowed();
        if (!$userIsAllowed) {
            return new JsonResponse([
                'status' => 'Error',
                'message' => 'The user is not allowed to delete a comment',
            ], 401);
        }

        $sourceUUID = $this->getSourceUUID();
        if (empty($sourceUUID)) {
            return new JsonResponse([
                'status' => 'Error',
                'message' => 'Source UUID header must be defined',
            ], 400);
        }
        
        $authorUUID = $this
            ->userCredentialsProvider
            ->getUUID();
        if (empty($authorUUID)) {
            return new JsonResponse([
                'status' => 'Error',
                'message' => 'Author UUID must be defined',
            ], 400);
        }

        $postParameterBag = $this
            ->request
            ->request;
        $commentId = $postParameterBag->get('comment_id');

        if (empty($commentId)) {
            return new JsonResponse([
                'status' => 'Error',
                'message' => 'Some query parameters are missing',
            ], 400);
        }

        $commentReference = new CommentUUID($commentId);
        $comment = $this
            ->commentRepository
            ->findComment($commentReference)
            ->getFirstComment();

        if (!$comment instanceof Comment) {
            return new JsonResponse([
                'status' => 'Error',
                'message' => 'Comment not found',
            ], 404);
        }

        if (!$this->userCredentialsProvider->isModerator()) {
            if ($comment->getAuthorUUID() !== $authorUUID) {
                return new JsonResponse([
                    'status' => 'Error',
                    'message' => 'You are not authorized to delete this comment',
                ], 401);
            }
        }

        $this
            ->commentRepository
            ->deleteComment($comment);
        $this->flushRepository();

        return new JsonResponse([
            'status' => 'OK',
            'comment' => 'Comment deleted',
        ], 200);
    }
195076
public function massUpdate(CommentsRequest $request)
    {
        $this->authorize('otherUpdate', $this->model);

        $comments = $this->model->whereIn('id', $request->comments);
        $messages = [];

        switch ($request->mass_action) {
            case 'published':
                if (! $comments->update(['is_approved' => true])) {
                    $messages[] = 'unable to published';
                }
                break;
            case 'unpublished':
                if (! $comments->update(['is_approved' => false])) {
                    $messages[] = 'unable to unpublished';
                }
                break;
            case 'delete':
                if (! $comments->get()->each->delete()) {
                    $messages[] = 'unable to delete';
                }
                break;
        }

        $message = empty($messages) ? 'msg.complete' : 'msg.complete_but_null';

        return $this->makeRedirect(true, 'admin.comments.index', $message);
    }
169574
public function destroy(Request $request, $id)
    {
        $slug = $this->getSlug($request);

        $dataType = Admin::model('DataType')->where('slug', '=', $slug)->first();

        // Check permission
        $this->authorize('delete', app($dataType->model_name));

        // Init array of IDs
        $ids = [];
        if (empty($id)) {
            // Bulk delete, get IDs from POST
            $ids = explode(',', $request->ids);
        } else {
            // Single item delete, get ID from URL or Model Binding
            $ids[] = $id instanceof Model ? $id->{$id->getKeyName()} : $id;
        }
        foreach ($ids as $id) {
            $data = call_user_func([$dataType->model_name, 'findOrFail'], $id);
            $this->cleanup($dataType, $data);
        }

        $displayName = count($ids) > 1 ? $dataType->display_name_plural : $dataType->display_name_singular;

        $res = $data->destroy($ids);

        $data = $res
            ? [
                'message'    => __('admin.generic.successfully_deleted')." {$displayName}",
                'alert-type' => 'success',
            ]
            : [
                'message'    => __('admin.generic.error_deleting')." {$displayName}",
                'alert-type' => 'error',
            ];

        if ($res) {
            event(new CrudDataDeleted($dataType, $data, $ids));
        }

        $requestQuery = (object) $request->query();

        if ($dataType->isBackToParentCrud($requestQuery)) {
            return redirect()
                ->route("admin.{$requestQuery->crud_slug}.{$requestQuery->crud_action}", $requestQuery->crud_id)
                ->with([
                    'message'    => __('admin.generic.successfully_added_new')." {$dataType->display_name_singular}",
                    'alert-type' => 'success',
                ]);
        }

        return redirect()->route("admin.{$dataType->slug}.index", $request->query())->with($data);
    }
353299
public function deleteAction(Request $request, PaymentServiceProvider $paymentServiceProvider)
    {
        $form = $this->createDeleteForm($paymentServiceProvider);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->remove($paymentServiceProvider);
            $em->flush();
        }

        return $this->redirectToRoute('ecommerce_paymentserviceprovider_index');
    }