Remove the specified resource from storage.

@param BooksRequest $request
@param  int $id
@return \Illuminate\Contracts\Http\Response
325373
public function destroy(BooksRequest $request, $id)
    {
        $book = $this->model->findOrFail($id);

        if (!$book->delete()) {
            return json()->internalError('Failed to delete !');
        }

        return json()->success('Deleted');
    }
1086765
public function destroy(Request $request, $id)
    {
        $this->slug = $this->getSlug($request);
        if (!$this->can('delete-' . Str::plural($this->slug), auth()->user()->id)) {
            abort(404);
        }
        Laramin::model($this->type->name)->find($id)->delete();

        Session::flash($this->flashname, $this->SessionMessage("Your {$this->slug} Has Been Succesfully Destroyed", 'success'));

        return redirect()->route("laramin.{$this->slug}.index");
    }
1089018
public function unlinkAction(Request $request, $id, $translationId)
    {

        /** @var PageInterface $page */
        $page = $this->admin->getObject($id);
        $translatedPage = $this->admin->getObject($translationId);

        if (!$page) {
            throw new NotFoundHttpException(sprintf('unable to find the Page with id : %s', $id));
        }

        if ($request->getMethod() == 'DELETE') {
            $page->removeTranslation($translatedPage);
            $translatedPage->removeTranslation($page);

            $this->admin->update($page);
            $this->admin->update($translatedPage);

            if ($this->isXmlHttpRequest()) {
                $html = $this->renderView(
                    '@NetworkingInitCms/PageAdmin/page_translation_settings.html.twig',
                    ['object' => $page, 'admin' => $this->admin]
                );

                return $this->renderJson(
                    [
                        'result' => 'ok',
                        'html' => $html,
                    ]
                );
            }

            $this->get('session')->getFlashBag()->add('sonata_flash_success', 'flash_link_success');

            return new RedirectResponse($this->admin->generateUrl('edit', ['id' => $page->getId()]));
        }

        return $this->renderWithExtraParams(
            '@NetworkingInitCms/PageAdmin/page_translation_unlink.html.twig',
            [
                'action' => 'unlink',
                'page' => $page,
                'translationId' => $translationId,
                'admin' => $this->admin,
                'translatedPage' => $translatedPage,
            ]
        );
    }
50802
public function cdeleteAction($id, Request $request)
    {
        list($webspaceKey, $languageCode) = $this->getWebspaceAndLanguage($request);
        $path = $this->getRequestParameter($request, 'ids', true); // TODO rename path to id in all function names

        $this->getResourceLocatorRepository()->delete($path, $webspaceKey, $languageCode);
        $this->getDocumentManager()->flush();

        return $this->handleView($this->view());
    }
754364
public function deleteAction($id, Request $request, $menuId = null)
    {
        $this->menuId = $menuId;

        return parent::deleteAction($id, $request);
    }
58104
public function deleteSession(Request $request, $id)
    {
        $session = $this->getSessionRepository()->find($id);

        if (null === $session) {
            $this->app->abort(404, 'Unknown session');
        }

        if (null === $session->getUser()) {
            $this->app->abort(403, 'Unauthorized');
        }

        if ($session->getUser()->getId() !== $this->getAuthenticatedUser()->getId()) {
            $this->app->abort(403, 'Unauthorized');
        }

        $manager = $this->getEntityManager();
        $manager->remove($session);
        $manager->flush();

        if ($request->isXmlHttpRequest()) {
            return $this->app->json([
                'success' => true,
                'session_id' => $id
            ]);
        }

        return $this->app->redirectPath('account_sessions');
    }
820438
public function deleteMediaAction(Request $request, $id)
    {
        $response = $this->getFilter($request);
        if ($response['success'] === false) {
            return $response['value'];
        }
        $filter = $response['value'];

        $mm = $this->getMediaManager();

        $media = $mm->findOneBy(array(
            'id' => $id,
            'filter' => $filter,
        ));

        if ($media !== null) {
            $media->setCryptedFilter($response['crypted']);
            $mm->delete($media);
        }

        return $this->createResponse($media);
    }
800972
public function remove(Request $request)
    {
        $app = $this->app;

        $store = $this->getStore();

        if (method_exists($this, 'beforeRemove')) {
            $response = $this->beforeRemove($request);

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

        $ids = $request->get('ids', array());

        if (count($ids) == 0) {
            $ids[] = $request->get('id');
        }

        $success = true;

        foreach ($ids as $idx => $id) {
            if (!$store->remove($id)) {
                $success = false;
            }
        }

        $response = [
            'success' => $success
        ];

        if (method_exists($this, 'afterRemove')) {
            $response = $this->afterRemove($request, $response);

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

        return $app->json($response);
    }
225396
public function removeitemAction(Request $request, $id) {
        $em = $this->getDoctrine()->getManager();

        $galleryItem = $em->getRepository('AmulenMediaBundle:GalleryItem')->find($id);

        $gallery = $galleryItem->getGallery();

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

        return $this->redirect($this->generateUrl('admin_gallery_items', array("id" => $gallery->getId())));
    }
795701
public function remove($id)
    {
        // Support removing many ids at once
        $ids = Request::has('ids') ? explode(',', request('ids')) : [$id];

        // Get the model instances for each id, for the purpose of event firing
        $items = array_map(function ($id) {
            return $this->findOrFail($id);
        }, $ids);

        // Lookup up the parent model so we can bulk remove multiple of THIS model
        foreach ($items as $item) {
            $item->fireDecoyEvent('removing', [$item, $this->parent]);
        }
        $this->parentRelation()->detach($ids);
        foreach ($items as $item) {
            $item->fireDecoyEvent('removed', [$item, $this->parent]);
        }

        // Redirect.  We can use back cause this is never called from a "show"
        // page like get_delete is.
        if (Request::ajax()) {
            return Response::json();
        }

        return Redirect::back();
    }
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);
    }
938279
public function destroy(Request $request, $id)
    {
        // Fetch the role object
        // $id = $this->decode($hash);
        $role = $this->roleRepository->findById($id);

        // Prevent the deletion of roles have the current user as a member
        if (Sentinel::inRole($role)) {
            if ($request->expectsJson()) {
                return response()->json("You must leave this group before it can be removed.", 422);
            }
            session()->flash('error', "You must leave this group before it can be removed.");
            return redirect()->back()->withInput();
        }

        // Remove the role
        $role->delete();

        // All done
        $message = "Role '{$role->name}' has been removed.";
        if ($request->expectsJson()) {
            return response()->json([$message], 200);
        }

        session()->flash('success', $message);
        return redirect()->route('roles.index');
    }
1075961
public function deleteAction(Request $request, $id)
    {

        $handler = new LanguageFormHandler(
            $this->createDeleteForm(),
            $request,
            $this->get('doctrine')->getManager(),
            $this->get('session')->getFlashBag()
        );


        $entity = $this->getDoctrine()->getRepository('BaconLanguageBundle:Language')->find($id);

        if ($handler->delete($entity)) {
            return $this->redirect($this->generateUrl('admin_language'));
        }

        return $this->redirect($this->generateUrl('admin_language_show', array('id' => $id)));
    }
1072637
public function removeById($id)
    {
        $qry = new InvokePostMethodQuery($this->getResourcePath(),"removebyid",array($id));
        $this->getContext()->addQuery($qry);
    }
247061
public function destroy(Request $request, $id)
    {
        $deleted = (new Services\GroupsService)->dataDelete($id, $request->all());
        return response()->json(['deleted' => $deleted]);
    }
927258
public function deleteAction(Request $request, $id)
    {

        $em = $this->getDoctrine()->getManager();
        $entity = $em->getRepository('EcommerceBundle:Transaction')->find($id);

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

        $em->remove($entity);
        $em->flush();
        
         $this->get('session')->getFlashBag()->add('info', 'transaction.deleted');
         
        return array();
    }
792123
public function deleteDestroy(ModelConfigurationInterface $model, Request $request, $id)
    {
        if (! $model->isRestorableModel()) {
            abort(404);
        }

        $item = $model->getRepository()->findOnlyTrashed($id);

        if (is_null($item) || ! $model->isRestorable($item)) {
            abort(404);
        }

        $model->fireDestroy($id);

        if ($model->fireEvent('destroying', true, $item, $request) === false) {
            return redirect()->back();
        }

        $model->getRepository()->forceDelete($id);

        $model->fireEvent('destroyed', false, $item, $request);

        return redirect($request->input('_redirectBack', back()->getTargetUrl()))
            ->with('success_message', $model->getMessageOnDestroy());
    }