我正在使用 laravel 8.0 制作一个多语言 Web 项目。为了使其成为多语言,我使用了https://github.com/mcamara/laravel-localization包。它适用于仪表板,但不适用于注册页面。错误是Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpExceptionThe GET method is not supported for this route. Supported methods: POST.
。要修复我在 <form: LaravelLocalization::getLocalizedURL{}
This is the register.blade.php 添加的错误:
<!-- Fields to complete Registration Step 1 -->
<form method="POST" action="{{ LaravelLocalization::getLocalizedURL('/register2') }}">
@csrf
<div>
<x-jet-label for="country_id" value="{{ ('Choose your country')}}"/>
<select id="country_id" name="country_id"
class=' w-full border-gray-300 focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 rounded-md shadow-sm'>
<option value="" disabled selected>Select Country</option>
<option value=""></option>
<option value=""></option>
</select>
</div>
这是路由器/web.php:
Route::group(
[
'prefix' => LaravelLocalization::setLocale(),
'middleware' => [ 'localeSessionRedirect', 'localizationRedirect', 'localeViewPath' ]
], function(){ //...
Route::get('/', function()
{
return redirect()->route('login');
});
Route::post('/register', 'App\Http\Controllers\RegisteredUserController@store')->name('register2');
Route::group(['middleware' => 'auth'],function (){
Route::get('/register-step2','\App\Http\Controllers\RegisterStepTwoController@create')
->name('register-step2.create');
Route::post('/register-step2','\App\Http\Controllers\RegisterStepTwoController@store')
->name('register-step2.post');
Route::group([ 'middleware' => ['auth:sanctum','verified','registered']], function() {
Route::get('/dashboard', '\App\Http\Controllers\DashboardController@index')->name('dashboard');
});
});
});
但现在它显示另一个错误:错误:在此处输入图像描述