I am translating my Laravel website, which uses the mcamara/laravel-localization package for translation. I have found that if somebody types a not existing language (f.e. http://localhost/de/test) there are some errors on the page. Because I don't want to check and repair all pages for that errors, I need some Middleware or Handler to check if the selected language is in the array with the translations and if not to redirect to 404 page.
Unfortunately I am not sure where to make that check ?
if(!in_array($lang, $languages)) {
App::abort(404);
}
return true;
Many thanks !