This commit is contained in:
Dennis
2025-01-07 10:31:44 +01:00
parent 528868c1df
commit 8b5c5734c1
2 changed files with 18 additions and 7 deletions

View File

@@ -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();
}
}

View File

@@ -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);
}