From 016c3c87a368e20b53dd7196f57b1514d35f9ffe Mon Sep 17 00:00:00 2001 From: Chrissle28 Date: Tue, 26 Apr 2022 13:43:55 +0200 Subject: [PATCH] add abort to 404 when current page doesn't exist --- src/Localize/LocalizeServiceProvider.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Localize/LocalizeServiceProvider.php b/src/Localize/LocalizeServiceProvider.php index 1467202..2500af3 100644 --- a/src/Localize/LocalizeServiceProvider.php +++ b/src/Localize/LocalizeServiceProvider.php @@ -99,7 +99,10 @@ protected function registerTranslatorMacro() if (lit()->isAppTranslatable()) { $routes->extend(function (Route $route) { $route->translator(function ($locale, $slug = null) { - $slug = Page::current()->translate($locale)->t_slug; + $slug = Page::current()?->translate($locale)->t_slug; + if (! $slug) { + abort(404); + } return ['slug' => $slug]; });