public function delete($modelName, $id)
    {
        $config        = app('itemconfig');
        $actionFactory = app('admin_action_factory');
        $baseModel     = $config->getDataModel();
        $model         = $baseModel::find($id);
        $errorResponse = array(
            'success' => false,
            'error'   => 'There was an error deleting this item. Please reload the page and try again.',
        );

        //if the model or the id don't exist, send back an error
        $permissions = $actionFactory->getActionPermissions();

        if (!$model->exists || !$permissions['delete']) {
            return response()->json($errorResponse);
        }

        //delete the model
        // 如果删除成功，或者数据库里面再也找不到了，就算成功
        if ($model->delete() || !$baseModel::find($id)) {
            return response()->json(array(
                'success' => true,
            ));
        } else {
            return response()->json($errorResponse);
        }
    }
public function delete($modelName, $id)
    {
        $config        = app('itemconfig');
        $actionFactory = app('admin_action_factory');
        $baseModel     = $config->getDataModel();
        $model         = $baseModel::find($id);
        $errorResponse = array(
            'success' => false,
            'error'   => 'There was an error deleting this item. Please reload the page and try again.',
        );

        //if the model or the id don't exist, send back an error
        $permissions = $actionFactory->getActionPermissions();

        if (!$model->exists || !$permissions['delete']) {
            return response()->json($errorResponse);
        }

        //delete the model
        // 如果删除成功，或者数据库里面再也找不到了，就算成功
        if ($model->delete() || !$baseModel::find($id)) {
            return response()->json(array(
                'success' => true,
            ));
        } else {
            return response()->json($errorResponse);
        }
    }
public function delete ( $ modelName , $ id ) { $ config = app ( 'itemconfig' ) ; $ actionFactory = app ( 'admin_action_factory' ) ; $ baseModel = $ config -> getDataModel ( ) ; $ model = $ baseModel :: find ( $ id ) ; $ errorResponse = array ( 'success' => false , 'error' => 'There was an error deleting this item. Please reload the page and try again.' , ) ; //if the model or the id don't exist, send back an error $ permissions = $ actionFactory -> getActionPermissions ( ) ; if ( ! $ model -> exists || ! $ permissions [ 'delete' ] ) { return response ( ) -> json ( $ errorResponse ) ; } //delete the model // 如果删除成功，或者数据库里面再也找不到了，就算成功 if ( $ model -> delete ( ) || ! $ baseModel :: find ( $ id ) ) { return response ( ) -> json ( array ( 'success' => true , ) ) ; } else { return response ( ) -> json ( $ errorResponse ) ; } }
POST delete method that accepts data via JSON POST and either saves an old.

@param string $modelName
@param int    $id

@return JSON
POST delete method that accepts data via JSON POST and either saves an old .