From 8b5c5734c19b6c4b1fb773fb1fd54adc4f4f9765 Mon Sep 17 00:00:00 2001 From: Dennis Date: Tue, 7 Jan 2025 10:31:44 +0100 Subject: [PATCH] fixes --- app/Models/AvailableServer.php | 21 ++++++++++++++++----- app/Services/Ploi/Ploi.php | 4 ++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/app/Models/AvailableServer.php b/app/Models/AvailableServer.php index c07f81d..9186ebe 100644 --- a/app/Models/AvailableServer.php +++ b/app/Models/AvailableServer.php @@ -2,6 +2,7 @@ namespace App\Models; +use Filament\Notifications\Notification; use stdClass; use Sushi\Sushi; use App\Services\Ploi\Ploi; @@ -14,13 +15,23 @@ class AvailableServer extends Model public function getRows(): array { - $availableServers = Ploi::make() - ->synchronize() - ->servers() - ->getData(); + try { + $availableServers = Ploi::make() + ->synchronize() + ->servers() + ->getData(); + } catch (\Throwable $e) { + Notification::make('wrong') + ->title('Synchronize') + ->body('Something went wrong when gathering the available servers: '. $e->getMessage()) + ->danger() + ->send(); + + return []; + } return collect($availableServers) - ->map(fn (stdClass $server): array => Arr::only((array) $server, ['id', 'name', 'ip_address', 'sites_count'])) + ->map(fn(stdClass $server): array => Arr::only((array)$server, ['id', 'name', 'ip_address', 'sites_count'])) ->all(); } } diff --git a/app/Services/Ploi/Ploi.php b/app/Services/Ploi/Ploi.php index 18c4632..98148cb 100644 --- a/app/Services/Ploi/Ploi.php +++ b/app/Services/Ploi/Ploi.php @@ -139,12 +139,12 @@ class Ploi return new Server($this, $id); } - public function user() + public function user(): User { return new User($this); } - public function synchronize() + public function synchronize(): Synchronize { return new Synchronize($this); }