]> BookStack Code Mirror - bookstack/blobdiff - app/Services/PermissionService.php
Updated Dutch language files
[bookstack] / app / Services / PermissionService.php
index 39a2c38beda24f795dbe4d0d0d88c3fec3a9f40f..72a810b6b4ebf657f6c29cd681141b930652a34c 100644 (file)
@@ -243,13 +243,14 @@ class PermissionService
      */
     protected function deleteManyJointPermissionsForEntities($entities)
     {
+        if (count($entities) === 0) return;
         $query = $this->jointPermission->newQuery();
-        foreach ($entities as $entity) {
-            $query->orWhere(function($query) use ($entity) {
-                $query->where('entity_id', '=', $entity->id)
-                    ->where('entity_type', '=', $entity->getMorphClass());
-            });
-        }
+            foreach ($entities as $entity) {
+                $query->orWhere(function($query) use ($entity) {
+                    $query->where('entity_id', '=', $entity->id)
+                        ->where('entity_type', '=', $entity->getMorphClass());
+                });
+            }
         $query->delete();
     }