Initial commit: Pireon Admin — headless admin panel and public API
Laravel 13 + Filament 5 admin panel and REST API for a non-profit developer collective, backed by the Pireon OAuth identity server. The public site is a separate, server-rendered application consuming /api/public/v1. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
60
app/Enums/GitProvider.php
Normal file
60
app/Enums/GitProvider.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use App\Services\Git\GitManager;
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
enum GitProvider: string implements HasLabel
|
||||
{
|
||||
case Gitea = 'gitea';
|
||||
case GitHub = 'github';
|
||||
case GitLab = 'gitlab';
|
||||
|
||||
public function getLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Gitea => '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<string, string> */
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())
|
||||
->mapWithKeys(fn (self $case) => [$case->value => $case->getLabel()])
|
||||
->all();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user