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(int $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; } return new App( $appAttributes['id'], $appAttributes['key'], $appAttributes['secret'], $appAttributes['name'] ?? null ); } }