> */ private array $settings = []; /** * @param class-string $setting */ public function register(string $setting): void { $this->settings[] = $setting; if (1 === count($this->settings)) { app(Router::class)->redirect('/setting', '/setting/' . $setting::group()); } } /** * @return array */ public function getShare(): array { return collect($this->settings)->map(fn ($setting) => [ 'url' => (new $setting)->url(), 'is_active' => url(request()->path()) === (new $setting)->url(), 'title' => $setting::title(), ]) ->toArray(); } public function resolveGroupName(string $name): LocalSettings { $settingClass = collect($this->settings)->first(fn ($setting) => $setting::group() === $name); return app($settingClass); } }