From 72b33a8bbaa564f863e2111e06c06421d168681b Mon Sep 17 00:00:00 2001 From: demn98 <79911094+demn98@users.noreply.github.com> Date: Wed, 20 Nov 2024 20:05:04 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=BF=D1=80=D0=B5=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=82=D0=B5=D0=BA=D1=83=D1=89=D0=B5?= =?UTF-8?q?=D0=B9=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D1=8B=20?= =?UTF-8?q?=D0=BF=D0=BE=20=D1=83=D0=BC=D0=BE=D0=BB=D1=87=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=8E=20(#253)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update Docs.php * Update DocsController.php * Update web.php --- app/Docs.php | 7 ++++++- app/Http/Controllers/DocsController.php | 7 ++++++- routes/web.php | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/Docs.php b/app/Docs.php index e3f38a4d..f9c0575e 100644 --- a/app/Docs.php +++ b/app/Docs.php @@ -17,6 +17,11 @@ class Docs { + /** + * Default document of Laravel documentation + */ + public const DEFAULT_DOCUMENT = 'installation'; + /** * Default version of Laravel documentation */ @@ -88,7 +93,7 @@ public function raw(): string // Abort the request if the page doesn't exist abort_if( $raw === null, - redirect(status: 300)->route('docs', ['version' => $this->version, 'page' => 'installation']) + redirect(status: 300)->route('docs', ['version' => $this->version, 'page' => self::DEFAULT_DOCUMENT]) ); return $raw; diff --git a/app/Http/Controllers/DocsController.php b/app/Http/Controllers/DocsController.php index e6b4aca1..d3ff6cc3 100644 --- a/app/Http/Controllers/DocsController.php +++ b/app/Http/Controllers/DocsController.php @@ -19,8 +19,13 @@ class DocsController extends Controller * * @return \Illuminate\View\View| */ - public function show(string $version = Docs::DEFAULT_VERSION, string $page = 'installation') + public function show(string $version = Docs::DEFAULT_VERSION, string $page = null) { + abort_if( + $page === null, + redirect(status: 300)->route('docs', ['version' => $version, 'page' => Docs::DEFAULT_DOCUMENT]) + ); + $docs = new Docs($version, $page); return $docs->view('docs.docs'); diff --git a/routes/web.php b/routes/web.php index c45274cc..31eb6910 100644 --- a/routes/web.php +++ b/routes/web.php @@ -394,7 +394,7 @@ Route::view('/documentation-contribution-guide', 'docs.contribution') ->name('documentation-contribution-guide'); -Route::redirect('/docs/', '/docs/'.Docs::DEFAULT_VERSION); +Route::redirect('/docs/', '/docs/'.Docs::DEFAULT_VERSION.'/'.Docs::DEFAULT_DOCUMENT); Route::get('/status/{version?}', [DocsController::class, 'status']) ->whereIn('version', Docs::SUPPORT_VERSIONS)