> */ private array $settings = []; /** * @param class-string $setting */ public function register(string $setting): void { $this->settings[] = $setting; if (new $setting() instanceof Viewable) { app(Router::class)->middleware(['web', 'auth:web', SettingMiddleware::class])->get($setting::url(), $setting::indexAction()); } if (new $setting() instanceof Storeable) { app(Router::class)->middleware(['web', 'auth:web'])->post($setting::url(), $setting::storeAction()); } 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()->path() === $setting::url(), 'title' => $setting::title(), ]) ->toArray(); } }