Bulk Delete post type.
Delete many post type in the same time.

@param  Request $request
@return array
@throws \Exception
167850
public function bulkDelete(Request $request)
    {
        // check if user has permissions to access this link
        if(!User::hasAccess('PostType', 'delete')) {
            return $this->noPermission();
        }
        // if there are no item selected
        if (count($request->all()) <= 0) {
            return $this->response('Please select items to be deleted', 500);
        }

        // loop throw the item array (ids) and delete them
        foreach($request->all() as $id){
            $res = $this->deletePostType($id);
            if(!$res) {
                return $this->response('Post Type could not be deleted. Please try again later or contact your Administrator!', 500);
            }
            if(!is_bool($res)) {
                return $res;
            }
        }
        return $this->response('Selected post types are successfully deleted', 200);
    }
1290431
public function deleteAjaxAction( Request $request ) {
		$id          = $request->get( 'id' );
		$pageId      = $request->get( 'pageId' );
		$uniqId      = $request->get( 'uniqId' );
		$code        = $request->get( 'code' );
		$formFieldId = $request->get( 'formFieldId' );

		if ( $id ) {
			$layoutBlock = $this->admin->getObject( $id );
			if ( $layoutBlock ) {
				$this->admin->delete( $layoutBlock );
			}
		}
		$html = $this->getLayoutBlockFormWidget( $pageId, $formFieldId, $uniqId, $code );

		return new JsonResponse( [
			'messageStatus' => 'success',
			'message'       => $this->translate( 'message.layout_block_deleted' ),
			'html'          => $html,
		] );
	}
230829
public function removeTranslationAction(Request $request): Response
    {
        $form = $this->contentTypeFormFactory->removeContentTypeTranslation(
            new TranslationRemoveData()
        );
        $form->handleRequest($request);

        /** @var TranslationRemoveData $data */
        $data = $form->getData();
        $contentType = $data->getContentType();
        $contentTypeGroup = $data->getContentTypeGroup();

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form, function (TranslationRemoveData $data) {
                $contentType = $data->getContentType();
                $languageCodes = $data->getLanguageCodes();
                $contentTypeGroup = $data->getContentTypeGroup();
                try {
                    $contentTypeDraft = $this->tryToCreateContentTypeDraft($contentType);
                } catch (BadStateException $e) {
                    $userId = $contentType->modifierId;
                    $this->notificationHandler->error(
                        $this->translator->trans(
                            /** @Desc("Draft of the Content Type '%name%' already exists and is locked by '%userContentName%'") */
                            'content_type.edit.error.already_exists',
                            ['%name%' => $contentType->getName(), '%userContentName%' => $this->getUserNameById($userId)],
                            'content_type'
                        )
                    );

                    return $this->redirectToRoute('ezplatform.content_type.view', [
                        'contentTypeGroupId' => $contentTypeGroup->id,
                        'contentTypeId' => $contentType->id,
                    ]);
                }
                foreach ($languageCodes as $languageCode => $isChecked) {
                    $newContentTypeDraft = $this->contentTypeService->removeContentTypeTranslation($contentTypeDraft, $languageCode);
                }
                $this->contentTypeService->publishContentTypeDraft($newContentTypeDraft);

                return new RedirectResponse($this->generateUrl('ezplatform.content_type.view', [
                    'contentTypeId' => $contentType->id,
                    'contentTypeGroupId' => $contentTypeGroup->id,
                    '_fragment' => TranslationsTab::URI_FRAGMENT,
                ]));
            });

            if ($result instanceof Response) {
                return $result;
            }
        }

        return $this->redirectToRoute('ezplatform.content_type.view', [
            'contentTypeGroupId' => $contentTypeGroup->id,
            'contentTypeId' => $contentType->id,
        ]);
    }
91422
public function multipledeleteinfoAction(Request $request)
    {
        $ids = $request->get('ids');

        $response = [];
        $numContacts = 0;
        $numChildren = 0;

        foreach ($ids as $id) {
            $account = $this->getRepository()->countDistinctAccountChildrenAndContacts($id);

            // Get number of subaccounts.
            $numChildren += $account['numChildren'];

            // FIXME: Distinct contacts: (currently the same contacts could be counted multiple times).
            // Get full number of contacts.
            $numContacts += $account['numContacts'];
        }

        $response['numContacts'] = $numContacts;
        $response['numChildren'] = $numChildren;

        $view = $this->view($response, 200);

        return $this->handleView($view);
    }
1048340
public function deleteAction(Request $request)
    {
        if (!$request->isXmlHttpRequest()) {
            throw new NotFoundHttpException();
        }

        $folder = $this->findFolderById($request->attributes->get('id'));

        $result = array();
        try {
            $this->removeFolder($folder);
        } catch (DBALException $e) {
            $result = array(
                'error'   => true,
                'message' => 'Ce dossier n\'est pas vide.',
            );
        }

        $response = new Response(json_encode($result, JSON_FORCE_OBJECT));
        $response->headers->add(array('Content-Type' => 'application/json'));
        return $response;
    }
1061767
public function bulkDelete(Request $request)
    {
        // check if user has permissions to access this link
        if(!User::hasAccess('CustomField', 'delete')) {
            return $this->noPermission();
        }
        $data = $request->all();
        foreach ($data as $id){
            $customFieldsGroup = CustomFieldGroup::find($id)->delete();
            if (!$customFieldsGroup) {
                return $this->response('Internal server error. Please try again later', 500);
            }else{
                CustomField::where('customFieldGroupID', $id)->delete();
                // TODO me i fshi vlerat e custom fildave neper poste, users dhe category
            }
        }
        return $this->response('Custom fields groups are deleted');
    }
541144
public function removeAction(Request $request)
    {
        $container = $this->findContainerByRequest($request);
        $content = $container->getContent();

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

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

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

        $data = [
            'removed' => [$removedId],
            //'contents' => [$this->getViewBuilder()->buildContent($content)],
        ];

        return $this->buildResponse($data, self::SERIALIZE_LAYOUT);
    }
579046
public function removeAction(Request $request)
    {
        $block = $this->findBlockByRequest($request);
        $row = $block->getRow();

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

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

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

        $data = [
            'removed' => [$removedId],
            //'rows'    => [$this->getViewBuilder()->buildRow($row)],
        ];

        return $this->buildResponse($data, self::SERIALIZE_LAYOUT);
    }
1216354
public function delete(Request $request)
    {
        $json = [];

        if ($request->get('directory')) {
            $this->storage->deleteDirectory($request->get('directory'));
            Image::deleteDirectory($this->path . $request->get('directory'));
            $json['success'] = trans('admin::image.success.delete');
        } elseif ($request->get('file')) {
            $this->storage->delete($request->get('file'));
            Image::delete($this->path . $request->get('file'));
            $json['success'] = trans('admin::image.success.delete');
        } else {
            $json['error'] = trans('admin::image.error.delete');
        }

        return response()
            ->json($json);
    }
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);
    }
1337052
public function deleteImage(Request $request)
    {
        $path = $request->get('path');

        $path = 'uploads/catalog/images/e/0/v/1382542458778.jpeg';
        $fileName = pathinfo($path, PATHINFO_BASENAME);
        $relativeDir = pathinfo($path, PATHINFO_DIRNAME);

        $sizes = config('avored-framework.image.sizes');
        foreach ($sizes as $sizeName => $widthHeight) {
            $imagePath = $relativeDir . DIRECTORY_SEPARATOR . $sizeName . '-' . $fileName;
            if (File::exists($imagePath)) {
                File::delete(storage_path('app/public/' . $imagePath));
            }
        }

        if (File::exists($path)) {
            File::delete(storage_path('app/public/' . $path));
        }
        return JsonResponse::create(['success' => true]);
    }
247620
public function postDeletePostalAddress(Request $request)
    {
        $pa = PostalAddress::findOrFail($request->input('postal_address_id'));

        if ($pa->user->userId != Auth::user()->userId) {
            return redirect('/account/postal-addresses')
                ->withErrors(["You can only delete your own postal addresses."]);
        }

        if ($pa->purchases()->count()) {
            return redirect('/account/postal-addresses')
                ->withErrors(["You cannot delete postal addresses that are associated with purchases."]);
        }

        $pa->delete();

        return redirect('/account/postal-addresses')
            ->withStatus('Postal address deleted.');
    }
493708
public function deleteAction(Request $request)
    {
        $this->mapper->delete($this->mapper->getResource($request->get('id')));

        return new Response('', 204);
    }
1360905
public function changeTypeAction(Request $request)
    {
        $container = $this->findContainerByRequest($request);

        $type = $request->request->get('type', null);

        $data = [];

        if ($type != $container->getType()) {
            try {
                $removed = $this->getEditor()->getContainerManager()->changeType($container, $type);
            } catch (EditorExceptionInterface $e) {
                return $this->handleException($e);
            }

            if (!empty($removed)) {
                $data['removed'] = $removed;
            }

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

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

        return $this->buildResponse($data, self::SERIALIZE_FULL);
    }
1236538
public function cdeleteAction(Request $request)
    {
        $manager = $this->getTaskManager();

        $ids = array_filter(explode(',', $request->get('ids')));
        foreach ($ids as $id) {
            $manager->remove($id);
        }

        $this->getEntityManager()->flush();

        return $this->handleView($this->view());
    }
485033
public function bulkDeleteAction(Request $request): Response
    {
        $this->denyAccessUnlessGranted(new Attribute('state', 'administrate'));
        $form = $this->formFactory->deleteObjectStateGroups(
            new ObjectStateGroupsDeleteData()
        );
        $form->handleRequest($request);

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form, function (ObjectStateGroupsDeleteData $data) {
                foreach ($data->getObjectStateGroups() as $objectStateGroupId => $selected) {
                    $objectStateGroup = $this->objectStateService->loadObjectStateGroup($objectStateGroupId);
                    $this->objectStateService->deleteObjectStateGroup($objectStateGroup);

                    $this->notificationHandler->success(
                        $this->translator->trans(
                            /** @Desc("Object state group '%name%' deleted.") */
                            'object_state_group.delete.success',
                            ['%name%' => $objectStateGroup->getName()],
                            'object_state'
                        )
                    );
                }
            });

            if ($result instanceof Response) {
                return $result;
            }
        }

        return $this->redirectToRoute('ezplatform.object_state.groups.list');
    }
647671
public function delete($request)
    {
        $entriesCleared = 0;

        if ($this->exists($request)) {
            foreach ($this->entries as $entry) {
                if ($entry['cacheData']) {
                    // delete each results of the manifest
                    if ($this->cache->delete($entry['cacheData'])) {
                        $entriesCleared++;
                    }
                }
            }
            // delete the manifest of data source
            $this->cache->delete($this->key);
        }
        return $entriesCleared;
    }