public function update($id, Request $request)
    {
        $routePermission = RoutePermission::find($id);

        if ($routePermission == null) {
            return response()->json(null, 404);
        }

        // validate
        $this->registerValidators();

        $validator = Validator::make($request->all(), [
            'route'         => 'sometimes|required|string|max:255|unique:route_permission,route,'.$id,
            'permissions'   => 'sometimes|required|array|max:255|rolePermission',
            'roles'         => 'sometimes|required|array|max:255|rolePermission'
        ]);

        if ($validator->fails()) {
            return response()->json(arrayView('phpsoft.users::errors/validation', [
                'errors' => $validator->errors()
            ]), 400);
        }

        $request['permissions'] = isset($request['permissions']) ?
            json_encode($request['permissions']) : $routePermission->permissions;
        $request['roles'] = isset($request['roles']) ?
            json_encode($request['roles']) : $routePermission->roles;

        // check current user is admin
        if (!(Auth::user() && Auth::user()->hasRole('admin'))) {
            return response()->json(null, 403);
        }

        // update permissions and roles for the route
        $routePermission = $routePermission->update($request->all());

        return response()->json(arrayView('phpsoft.users::routePermission/read', [
            'routePermission' => $routePermission
        ]), 200);
    }