Destroy given service media.

@param \Cortex\Bookings\Models\Service   $service
@param \Spatie\MediaLibrary\Models\Media $media

@return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
513442
public function destroy(Service $service, Media $media)
    {
        $service->media()->where($media->getKeyName(), $media->getKey())->first()->delete();

        return intend([
            'url' => route('adminarea.services.media.index', ['service' => $service]),
            'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/foundation::common.media'), 'identifier' => $media->getRouteKey()])],
        ]);
    }
203991
public function deleteAction(Request $request)
    {
        $fileId = $request->get('file_id');
        $fileIds = explode(',', $fileId);

        $volumeManager = $this->get('phlexible_media_manager.volume_manager');

        foreach ($fileIds as $fileId) {
            try {
                $volume = $volumeManager->getByFileId($fileId);
                $file = $volume->findFile($fileId);
                $volume->deleteFile($file, $this->getUser()->getId());
            } catch (NotFoundException $e) {
            }
        }

        return new ResultResponse(true, count($fileIds).' file(s) deleted.');
    }
430845
public function delForeverMedia($media_id){
        if (!$this->access_token && !$this->checkAuth()) return false;
        $data = array('media_id' => $media_id);
        $result = $this->http_post(self::API_URL_PREFIX.self::MEDIA_FOREVER_DEL_URL.'access_token='.$this->access_token,self::json_encode($data));
        if ($result)
        {
            $json = json_decode($result,true);
            if (!$json || !empty($json['errcode'])) {
                $this->errCode = $json['errcode'];
                $this->errMsg = $json['errmsg'];
                return false;
            }
            return true;
        }
        return false;
    }
598631
public function destroy($id)
    {
        $result = $this->service->destroy($id);

        if ($result) {
            return redirect('admin/features')->with('message', 'Successfully deleted');
        }

        return redirect('admin/features')->with('errors', ['Failed to delete']);
    }
236520
public function destroy(Tenant $tenant, Media $media)
    {
        $tenant->media()->where($media->getKeyName(), $media->getKey())->first()->delete();

        return intend([
            'url' => route('adminarea.tenants.media.index', ['tenant' => $tenant]),
            'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/foundation::common.media'), 'identifier' => $media->getRouteKey()])],
        ]);
    }
93757
public function destroy($id)
    {
        $this->service->destroy($id);
        flash()->success('Se ha eliminado el artículo');
        return redirect()->to('backend/blog');
    }
819517
public function delete($mediaId)
    {
        return Response::json($this->curl->post(self::DELETE.$this->access_token, json_encode([
                    'media_id' => $mediaId,
                ]
            )
        )
        );
    }
578653
@Given("^I destroy service '(.+?)' in cluster '(.+?)'")
    public void destroyService(String service, String cluster) throws Exception {
        String endPoint = "/service/deploy-api/deploy/uninstall?app=" + service;
        Future response;

        this.commonspec.setRestProtocol("https://");
        this.commonspec.setRestHost(cluster);
        this.commonspec.setRestPort(":443");

        response = this.commonspec.generateRequest("DELETE", true, null, null, endPoint, null, "json");

        this.commonspec.setResponse("DELETE", (Response) response.get());
        assertThat(this.commonspec.getResponse().getStatusCode()).as("It hasn't been possible to destroy service: " + service).isIn(Arrays.asList(200, 202));
    }
492296
public function destroy($id)
    {
        try {
            $result = $this->service->destroy(Auth::user(), $id);

            if ($result) {
                return redirect('teams')->with('message', 'Successfully deleted');
            }

            return redirect('teams')->with('message', 'Failed to delete');
        } catch (Exception $e) {
            return back()->withErrors($e->getMessage());
        }
    }
442610
public function clearToken($service)
    {
        $service = $this->normalizeServiceName($service);

        $tokens = $this->sessionScope->get(self::SESSION_TOKEN);
        if (array_key_exists($service, $tokens)) {
            unset($tokens, $service);
        }
        $this->sessionScope->set(self::SESSION_TOKEN, $tokens);

        return $this;
    }
944845
public function removeAction($mediaId)
    {
        $media = $this->getMedia($mediaId);
        $request = $this->getRequest();
        if ($request->request->get('confirm') === 'yes' || $request->get('confirm') === 'yes')
        {
            $this->get('fulgurio_light_cms.media_library')->remove($media);
            $em = $this->getDoctrine()->getManager();
            $em->remove($media);
            $em->flush();
            return $this->redirect($this->generateUrl('AdminMedias'));
        }
        else if ($request->request->get('confirm') === 'no')
        {
            return $this->redirect($this->generateUrl('AdminMedias', array('mediaId' => $mediaId)));
        }
        $templateName = $request->isXmlHttpRequest() ? 'FulgurioLightCMSBundle::adminConfirmAjax.html.twig' : 'FulgurioLightCMSBundle::adminConfirm.html.twig';
        return $this->render($templateName, array(
            'action' => $this->generateUrl('AdminMediasRemove', array('mediaId' => $mediaId)),
            'confirmationMessage' => $this->get('translator')->trans('fulgurio.lightcms.medias.delete_confirm_message', array('%FILENAME%' => $media->getOriginalName()), 'admin'),
        ));
    }
150943
public function delete(Request $request)
    {
        $isOk = "OK";
        // loop throw file array
        foreach ($request->all() as $key => $file){
            if ($key === "postTypes") {
                continue;
            }

            // check if user has permissions to access this link
            if(!User::hasAccess('Media', 'delete', $file['mediaID'], true)) {
                return $this->noPermission();
            }

            // get file info from database
            $media = Media::find($file['mediaID']);
            MediaRelation::where("mediaID", $file['mediaID'])->delete();
            if ($media->delete()) { // delete from database
                if(file_exists($media->url)) {
                    unlink($media->url); // delete original file
                }
                $media->deleteThumbs();
            }else{
                $isOk =  "ERR";
            }
        }
        return $isOk;
    }
1015916
private function deleteExistingFile(Media $model)
    {
        $this->filesystem->disk($model->disk)->delete($model->getDiskPath());
    }
1265527
public function removeActivity(string $servicename):Renderer
    {
        $removeservice = false;
        $file = JL::open(FEnv::get("framework.config.core.services.file"));
        foreach ($file as $one => $value) {
            if ($one == $servicename) {
                unset($file->$one);
                $removeservice  = true;
                break;
            }
        }

        if ($removeservice == false) {
            return ((new Renderer())->jsonRenderer(array("code" => 500, "msg" => "Service does not exist")));
        }

        $render = json_encode($file, JSON_PRETTY_PRINT);
        file_put_contents(FEnv::get("framework.config.core.services.file"), $render);

        return ((new Renderer())->jsonRenderer(array("code" => 200, "msg" => "OK")));
    }
518538
public function deleteAction(Request $request, $mediaId)
    {
        $em = $this->getDoctrine()->getManager();

        /* @var Media $media */
        $media = $em->getRepository('KunstmaanMediaBundle:Media')->getMedia($mediaId);
        $medianame = $media->getName();
        $folder = $media->getFolder();

        $em->getRepository('KunstmaanMediaBundle:Media')->delete($media);

        $this->addFlash(
            FlashTypes::SUCCESS,
            $this->get('translator')->trans(
                'kuma_admin.media.flash.deleted_success.%medianame%',
                [
                    '%medianame%' => $medianame,
                ]
            )
        );

        // If the redirect url is passed via the url we use it
        $redirectUrl = $request->query->get('redirectUrl');
        if (empty($redirectUrl) || (\strpos($redirectUrl, $request->getSchemeAndHttpHost()) !== 0 && \strpos($redirectUrl, '/') !== 0)) {
            $redirectUrl = $this->generateUrl(
                'KunstmaanMediaBundle_folder_show',
                ['folderId' => $folder->getId()]
            );
        }

        return new RedirectResponse($redirectUrl);
    }
351209
public DeleteMediaResourceResponse deleteMediaResource(String mediaId) {
        DeleteMediaResourceRequest request = new DeleteMediaResourceRequest().withMediaId(mediaId);
        return deleteMediaResource(request);
    }
1129133
public function deleteMedia(Request $request)
    {
        // if single file/folder '?s=name'
        if ($request->has('s')) {
            if (is_dir(storage_path('app') . DIRECTORY_SEPARATOR . $request->input('s'))) {
                return $this->deleteDirectory($request);
            } else {
                return $this->deleteFile($request);
            }
        }

        // if multiple files
        if ($request->has('files')) {
            Storage::delete($request->input('files'));
        }

        // if multiple directories
        if ($request->has('directories')) {
            if (is_array($request->input('directories'))) {
                foreach ($request->input('directories') as $directory) {
                    Storage::deleteDirectory($directory);
                }
            } else {
                Storage::deleteDirectory($request->input('directories'));
            }
        }

        if ($request->wantsJson()) {
            return $this->notifySuccess('File/Folder deleted successfully!');
        }

        flash()->success('File/Folder deleted successfully!');

        return redirect()->back();
    }