> */ private array $settings = []; /** * @param class-string $setting */ public function register(string $setting): void { $this->settings[] = $setting; app(Router::class)->middleware(['web', 'auth:web', SettingMiddleware::class])->get($setting::url(), $setting::indexAction()); app(Router::class)->middleware(['web', 'auth:web', SettingMiddleware::class])->post($setting::url(), $setting::saveAction()); if (1 === count($this->settings)) { app(Router::class)->redirect('/setting', '/setting/'.$setting::slug()); } } /** * @return array */ public function getShare(): array { return collect($this->settings)->map(fn ($setting) => [ 'url' => $setting::url(), 'is_active' => request()->fullUrlIs(url($setting::url())), 'title' => $setting::title(), ]) ->toArray(); } }