public function delete(Request $request, $bas_id)
    {
        $success = false;
        $msg = $this->app->trans('An error occured');

        $collection = \collection::getByBaseId($this->app, $bas_id);

        try {
            if ($collection->get_record_amount() > 0) {
                $msg = $this->app->trans('Empty the collection before removing');
            } else {
                $collection->unmount();
                $collection->delete();
                $success = true;
                $msg = $this->app->trans('Successful removal');
            }
        } catch (\Exception $e) {
        }

        if ('json' === $request->getRequestFormat()) {
            return $this->app->json([
                'success' => $success,
                'msg'     => $msg
            ]);
        }

        if ($collection->get_record_amount() > 0) {
            return $this->app->redirectPath('admin_display_collection', [
                'bas_id'  => $collection->get_sbas_id(),
                'success' => 0,
                'error'   => 'collection-not-empty',
            ]);
        }

        if ($success) {
            return $this->app->redirectPath('admin_display_collection', [
                'bas_id'      => $collection->get_sbas_id(),
                'success'     => 1,
                'reload-tree' => 1,
            ]);
        }

        return $this->app->redirectPath('admin_display_collection', [
            'bas_id'  => $collection->get_sbas_id(),
            'success' => 0,
        ]);
    }
public function delete(Request $request, $bas_id)
    {
        $success = false;
        $msg = $this->app->trans('An error occured');

        $collection = \collection::getByBaseId($this->app, $bas_id);

        try {
            if ($collection->get_record_amount() > 0) {
                $msg = $this->app->trans('Empty the collection before removing');
            } else {
                $collection->unmount();
                $collection->delete();
                $success = true;
                $msg = $this->app->trans('Successful removal');
            }
        } catch (\Exception $e) {
        }

        if ('json' === $request->getRequestFormat()) {
            return $this->app->json([
                'success' => $success,
                'msg'     => $msg
            ]);
        }

        if ($collection->get_record_amount() > 0) {
            return $this->app->redirectPath('admin_display_collection', [
                'bas_id'  => $collection->get_sbas_id(),
                'success' => 0,
                'error'   => 'collection-not-empty',
            ]);
        }

        if ($success) {
            return $this->app->redirectPath('admin_display_collection', [
                'bas_id'      => $collection->get_sbas_id(),
                'success'     => 1,
                'reload-tree' => 1,
            ]);
        }

        return $this->app->redirectPath('admin_display_collection', [
            'bas_id'  => $collection->get_sbas_id(),
            'success' => 0,
        ]);
    }
public function delete ( Request $ request , $ bas_id ) { $ success = false ; $ msg = $ this -> app -> trans ( 'An error occured' ) ; $ collection = \ collection :: getByBaseId ( $ this -> app , $ bas_id ) ; try { if ( $ collection -> get_record_amount ( ) > 0 ) { $ msg = $ this -> app -> trans ( 'Empty the collection before removing' ) ; } else { $ collection -> unmount ( ) ; $ collection -> delete ( ) ; $ success = true ; $ msg = $ this -> app -> trans ( 'Successful removal' ) ; } } catch ( \ Exception $ e ) { } if ( 'json' === $ request -> getRequestFormat ( ) ) { return $ this -> app -> json ( [ 'success' => $ success , 'msg' => $ msg ] ) ; } if ( $ collection -> get_record_amount ( ) > 0 ) { return $ this -> app -> redirectPath ( 'admin_display_collection' , [ 'bas_id' => $ collection -> get_sbas_id ( ) , 'success' => 0 , 'error' => 'collection-not-empty' , ] ) ; } if ( $ success ) { return $ this -> app -> redirectPath ( 'admin_display_collection' , [ 'bas_id' => $ collection -> get_sbas_id ( ) , 'success' => 1 , 'reload-tree' => 1 , ] ) ; } return $ this -> app -> redirectPath ( 'admin_display_collection' , [ 'bas_id' => $ collection -> get_sbas_id ( ) , 'success' => 0 , ] ) ; }
Delete a Collection

@param  Request $request The current request
@param  integer $bas_id  The collection base_id
@return Response
Delete a Collection