BookStack\Services\PermissionService::entityRestrictionQuery PHP Method

entityRestrictionQuery() protected method

The general query filter to remove all entities that the current user does not have access to.
protected entityRestrictionQuery ( $query ) : mixed
$query
return mixed
    protected function entityRestrictionQuery($query)
    {
        $q = $query->where(function ($parentQuery) {
            $parentQuery->whereHas('jointPermissions', function ($permissionQuery) {
                $permissionQuery->whereIn('role_id', $this->getRoles())->where('action', '=', $this->currentAction)->where(function ($query) {
                    $query->where('has_permission', '=', true)->orWhere(function ($query) {
                        $query->where('has_permission_own', '=', true)->where('created_by', '=', $this->currentUser()->id);
                    });
                });
            });
        });
        $this->clean();
        return $q;
    }