canManage($user)) { return true; } $excluded = $this->excludedRoles(); return $excluded === [] || ! $user->roles()->whereIn('roles.id', $excluded)->exists(); } /** * @return list */ public function excludedRoles(): array { return array_values(array_map('intval', (array) $this->settings->get(self::EXCLUDED_ROLES, []))); } public function canManage(?User $user): bool { return (bool) $user?->can('qm.manage'); } }