getUser(); if (!$user instanceof User) { return false; } switch ($attribute) { case 'edit': case 'delete': // changing existing teams should be limited to admins and teamleads if (!$user->isAdmin() && !$user->isSuperAdmin() && !$user->isTeamleadOf($subject)) { return false; } } return $this->permissionManager->hasRolePermission($user, $attribute . '_team'); } }