Also removed now unused view.
/**
* 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;
}
/**
$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(['*']);
}
protected function filterIsRestricted(EloquentBuilder $query, Entity $model, $input)
{
- $query->where('restricted', '=', true);
+ $query->whereHas('permissions');
}
protected function filterViewedByMe(EloquentBuilder $query, Entity $model, $input)
<h5>{{ trans('common.details') }}</h5>
<div class="blended-links">
@include('entities.meta', ['entity' => $book])
- @if($book->restricted)
+ @if($book->hasPermissions())
<div class="active-restriction">
@if(userCan('restrictions-manage', $book))
<a href="{{ $book->getUrl('/permissions') }}" class="entity-meta-item">
<div class="blended-links">
@include('entities.meta', ['entity' => $chapter])
- @if($book->restricted)
+ @if($book->hasPermissions())
<div class="active-restriction">
@if(userCan('restrictions-manage', $book))
<a href="{{ $book->getUrl('/permissions') }}" class="entity-meta-item">
</div>
@endif
- @if($chapter->restricted)
+ @if($chapter->hasPermissions())
<div class="active-restriction">
@if(userCan('restrictions-manage', $chapter))
<a href="{{ $chapter->getUrl('/permissions') }}" class="entity-meta-item">
+++ /dev/null
-{{--
-$name
-$label
-$role
-$action
-$model?
---}}
-@include('form.custom-checkbox', [
- 'name' => $name . '[' . $role->id . '][' . $action . ']',
- 'label' => $label,
- 'value' => 'true',
- 'checked' => isset($model) && $model->hasRestriction($role->id, $action)
-])
\ No newline at end of file
<div class="blended-links">
@include('entities.meta', ['entity' => $page])
- @if($book->restricted)
+ @if($book->hasPermissions())
<div class="active-restriction">
@if(userCan('restrictions-manage', $book))
<a href="{{ $book->getUrl('/permissions') }}" class="entity-meta-item">
</div>
@endif
- @if($page->chapter && $page->chapter->restricted)
+ @if($page->chapter && $page->chapter->hasPermissions())
<div class="active-restriction">
@if(userCan('restrictions-manage', $page->chapter))
<a href="{{ $page->chapter->getUrl('/permissions') }}" class="entity-meta-item">
</div>
@endif
- @if($page->restricted)
+ @if($page->hasPermissions())
<div class="active-restriction">
@if(userCan('restrictions-manage', $page))
<a href="{{ $page->getUrl('/permissions') }}" class="entity-meta-item">
<h5>{{ trans('common.details') }}</h5>
<div class="blended-links">
@include('entities.meta', ['entity' => $shelf])
- @if($shelf->restricted)
+ @if($shelf->hasPermissions())
<div class="active-restriction">
@if(userCan('restrictions-manage', $shelf))
<a href="{{ $shelf->getUrl('/permissions') }}" class="entity-meta-item">