public function scopeWherePermissionIs($query, $permission = '', $boolean = 'and')
    {
        $method = $boolean == 'and' ? 'where' : 'orWhere';

        return $query->$method(function ($query) use ($permission) {
            $query->whereHas('roles.permissions', function ($permissionQuery) use ($permission) {
                $permissionQuery->where('name', $permission);
            })->orWhereHas('permissions', function ($permissionQuery) use ($permission) {
                $permissionQuery->where('name', $permission);
            });
        });
    }