'Gitea', self::GitHub => 'GitHub', self::GitLab => 'GitLab', }; } public static function default(): self { return self::tryFrom((string) config('git.default')) ?? self::Gitea; } /** * A provider is usable only when it has a driver registered *and* that * driver has what it needs. * * The distinction matters for self-hosted providers: Gitea has a driver, * but without GITEA_URL there is no instance to talk to, and offering it * in the panel would only produce failures later. */ public function isSupported(): bool { $config = config("git.providers.{$this->value}"); if (! is_array($config) || ! isset($config['driver'])) { return false; } return rescue( fn () => app(GitManager::class)->driver($this)->isConfigured(), rescue: false, report: false, ); } /** @return array */ public static function options(): array { return collect(self::cases()) ->mapWithKeys(fn (self $case) => [$case->value => $case->getLabel()]) ->all(); } }