diff --git a/app/Entities/Models/Entity.php b/app/Entities/Models/Entity.php index a5254875d..4c399584b 100644 --- a/app/Entities/Models/Entity.php +++ b/app/Entities/Models/Entity.php @@ -182,12 +182,9 @@ abstract class Entity extends Model implements Sluggable, Favouritable, Viewable /** * Check if this entity has a specific restriction set against it. */ - public function hasRestriction(int $role_id, string $action): bool + public function hasPermissions(): bool { - return $this->permissions() - ->where('role_id', '=', $role_id) - ->where($action, '=', true) - ->count() > 0; + return $this->permissions()->count() > 0; } /** diff --git a/app/Search/SearchRunner.php b/app/Search/SearchRunner.php index e36edb06c..cc44e6125 100644 --- a/app/Search/SearchRunner.php +++ b/app/Search/SearchRunner.php @@ -162,7 +162,7 @@ class SearchRunner $entityQuery = $entityModelInstance->newQuery()->scopes('visible'); if ($entityModelInstance instanceof Page) { - $entityQuery->select(array_merge($entityModelInstance::$listAttributes, ['restricted', 'owned_by'])); + $entityQuery->select(array_merge($entityModelInstance::$listAttributes, ['owned_by'])); } else { $entityQuery->select(['*']); } @@ -447,7 +447,7 @@ class SearchRunner protected function filterIsRestricted(EloquentBuilder $query, Entity $model, $input) { - $query->where('restricted', '=', true); + $query->whereHas('permissions'); } protected function filterViewedByMe(EloquentBuilder $query, Entity $model, $input) diff --git a/resources/views/books/show.blade.php b/resources/views/books/show.blade.php index 76a4a6005..b95b69d1b 100644 --- a/resources/views/books/show.blade.php +++ b/resources/views/books/show.blade.php @@ -71,7 +71,7 @@