apps = collect(config('websockets.apps')); } /** @return array[\BeyondCode\LaravelWebSockets\AppProviders\App] */ public function all(): array { return $this->apps ->map(function (array $appAttributes) { return $this->instanciate($appAttributes); }) ->toArray(); } public function findById($appId): ?App { $appAttributes = $this ->apps ->firstWhere('id', $appId); return $this->instanciate($appAttributes); } public function findByKey(string $appKey): ?App { $appAttributes = $this ->apps ->firstWhere('key', $appKey); return $this->instanciate($appAttributes); } protected function instanciate(?array $appAttributes): ?App { if (! $appAttributes) { return null; } $app = new App( $appAttributes['id'], $appAttributes['key'], $appAttributes['secret'] ); if (isset($appAttributes['name'])) { $app->setName($appAttributes['name']); } if ($appAttributes['enable_client_messages'] ?? false) { $app->enableClientMessages(); } return $app; } }