[英]Laravel registration route doesn't work with localization package
我使用这个包进行本地化https://github.com/mcamara/laravel-localization ...
我已经设置了'hideDefaultLocaleInURL' => true,
。 我的默认语言环境是德语,所以当我进入注册页面时,URL 是http://localhost:8000/register
,一切正常。 但是如果用户选择英语( http://localhost:8000/en/register
)它不会注册用户,它只是重定向回注册表。
我认为注册路由定义有问题。 有没有办法来解决这个问题?
这是我的注册路线列表:
POST - register - App\Http\Controllers\Auth\RegisterController@register
GET - register
App\Http\Controllers\Auth\RegisterController@showRegistrationForm
本地化包中的中间件应用于这些路由:
web,localeSessionRedirect,localizat
ionRedirect,guest
我有这个,对我来说很好用。 尝试设置我的路线;
<?php
Route::group(
[
'prefix' => LaravelLocalization::setLocale(),
'middleware' => ['localize', 'localeSessionRedirect', 'localizationRedirect', 'localeViewPath' ]
],
function()
{
/**
* Auth and login routes
*/
// Authentication Routes...
Auth::routes();
}
);
这个问题已经很老了,但我在 Laravel 7 中遇到了同样的问题。如果有人仍然遇到同样的问题,我会通过在中间件 handle() 中添加一行来以某种方式解决了这个问题。
URL::defaults(['locale' => $request->segment(1)]);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.