Delete asset by id

DELETE /assets/{id}.json

@param string $id The asset id

@return array
351496
public function assetsDelete($id)
    {
        $resource = '/assets/' . $id . '.json';

        // Create request
        $data = $this->auth->request('DELETE', $resource);

        return $data;
    }
49752
public static function destroy($id) 
    {
        try {
            $file = self::find($id);
            
            if($file->descendants()->exists()) {
                foreach($file->descendants()->where('type', '!=', 'folder')->get() as $descendant) {
                    
                    event(new FileWasDeleted([ // fire 'file deleted' event for each descendant
                        'file' => $descendant
                    ]));
                }
            }
            
            $file->delete($id);

            if($file->type != 'folder') {
                event(new FileWasDeleted([ // fire 'file deleted' event for file
                    'file' => $file
                ]));
            }
        }
        
        catch (Exception $e) {
            throw $e;
        }
    }
950427
public function deleteAction($id)
    {
        $this->view->disable();
        $banner = Banner::findFirstByid($id);
        if (!$banner) {
            $alert  = "error";
            $msg    = "banner not Found";
        }
        if (! empty($banner->file)) {
            if(file_exists($this->path.$banner->file)){
                unlink($this->path.$banner->file);
            }
        }
        if (!$banner->delete()) {
            $alert  = "error";
            $msg    = " ";
            foreach ($banner->getMessages() as $message) {
                $msg .= $message." ";
            }
        }else{
            $alert  = "sukses";
            $msg    = "banner was deleted ";
        }

        $response = new \Phalcon\Http\Response();
        $response->setContentType('application/json', 'UTF-8');
        $response->setJsonContent(array('_id' => $id,'alert' => $alert, 'msg' => $msg ));
        return $response->send();
    }
1039674
public function destroy($id)
    {
        // get permission by id
        $permission = Permission::find($id);

        if (!$permission) {
            return response()->json(null, 404);
        }

        // delete permission
        $deletePermission = $permission->delete();

        if (!$deletePermission) {
            return response()->json(null, 500); // @codeCoverageIgnore
        }

        return response()->json(null, 204);
    }
956124
public function delete($id)
	{
		return file_exists($this->_cache_path.$id) ? unlink($this->_cache_path.$id) : FALSE;
	}
21854
public function destroy($id)
    {
        $this->entriesRepository->delete($id, $this->resource);

        return response()->json(['status' => 'ok']);
    }
1023142
public function actionDelete($id)
    {
        $this->findModel($id)->updateAttributes(['status' => User::STATUS_DELETED]);

        return $this->redirect(['index']);
    }
1296563
public function remove($id) {
    if (empty($id) || !is_numeric($id)) {
      throw new InvalidArgumentException('ID must be numeric');
    }
    return $this->delete('assets/email/' . rawurlencode($id));
  }
1205122
public function deleteAction($id)
    {
        $request = $this->getRequest();
        $id = $request->get($this->admin->getIdParameter());
        $object = $this->admin->getObject($id);

        if (!$object) {
            throw $this->createNotFoundException(sprintf('unable to find the object with id: %s', $id));
        }

        $this->checkParentChildAssociation($request, $object);

        $this->admin->checkAccess('delete', $object);

        $preResponse = $this->preDelete($request, $object);
        if (null !== $preResponse) {
            return $preResponse;
        }

        if ('DELETE' === $this->getRestMethod()) {
            // check the csrf token
            $this->validateCsrfToken('sonata.delete');

            $objectName = $this->admin->toString($object);

            try {
                $this->admin->delete($object);

                if ($this->isXmlHttpRequest()) {
                    return $this->renderJson(['result' => 'ok'], 200, []);
                }

                $this->addFlash(
                    'sonata_flash_success',
                    $this->trans(
                        'flash_delete_success',
                        ['%name%' => $this->escapeHtml($objectName)],
                        'SonataAdminBundle'
                    )
                );
            } catch (ModelManagerException $e) {
                $this->handleModelManagerException($e);

                if ($this->isXmlHttpRequest()) {
                    return $this->renderJson(['result' => 'error'], 200, []);
                }

                $this->addFlash(
                    'sonata_flash_error',
                    $this->trans(
                        'flash_delete_error',
                        ['%name%' => $this->escapeHtml($objectName)],
                        'SonataAdminBundle'
                    )
                );
            }

            return $this->redirectTo($object);
        }

        // NEXT_MAJOR: Remove this line and use commented line below it instead
        $template = $this->admin->getTemplate('delete');
        // $template = $this->templateRegistry->getTemplate('delete');

        return $this->renderWithExtraParams($template, [
            'object' => $object,
            'action' => 'delete',
            'csrf_token' => $this->getCsrfToken('sonata.delete'),
        ], null);
    }
1176423
public function delete($id) {
        $this->checkPermissions('delete');
        
        return $this->client->deleteData($this->resourceName . '/' . $id);
    }
525106
public function destroy($id)
    {
        try {
            $this->file->destroy($id);
        
            return response()->json([
                'status' => 'success'
            ]);
        } 

        catch (Exception $e) {
            return $this->handleError($e);
        }
    }
1247177
public function actionRemove(string $id): array
    {
        $items = Yii::$app->getRequest()->post('items', []);
        $model = $this->findModel($id);
        $model->removeChildren($items);

        return array_merge($model->getItems());
    }
744404
public function delete($id)
    {
        $this->fireEvent('deleting', [$id]);

        $deleted = $this->model->destroy($id);

        $this->fireEvent('deleted', [$id, $deleted]);

        return $deleted;
    }
809512
public function delete(int $id)
    {
        return self::$curl->post(self::DELETE.self::$access_token, json_encode([
                'tag' => [
                    'id' => $id,
                ],
            ]
        ));
    }
194529
public function delete($id)
    {
        $idName = ucfirst($this->idProperty->getName());
        return $this->__call("deleteBy$idName", array($id));
    }
806564
public function delete($id)
    {
        if ($this->hasDeleteTrait($this->modelInstance)) {
            return $this->destroy($id);
        }

        return $this->modelInstance->destroy($id);
    }
806405
public function actionDelete($id)
    {
        if (Yii::$app->request->isPost) {
            $this->findModel($id)->delete();
        }
        return $this->redirect(['index']);
    }