+ /**
+ * @param string[] $ids
+ * @param int[] $filterRoleIds
+ * @return EntityPermission[]
+ */
+ protected function getPermissionsForEntityIdsOfType(string $type, array $ids, array $filterRoleIds): array
+ {
+ $query = EntityPermission::query()
+ ->where('entity_type', '=', $type)
+ ->whereIn('entity_id', $ids);
+
+ if (!empty($filterRoleIds)) {
+ $query->where(function (Builder $query) use ($filterRoleIds) {
+ $query->whereIn('role_id', [...$filterRoleIds, 0]);
+ });
+ }
+
+ return $query->get(['entity_id', 'entity_type', 'role_id', $this->action])->all();
+ }
+