[路由:verification.verify] [URI:{locale}/email/verify/{id}/{hash}] 缺少必需的参数

Missing required parameters for [Route: verification.verify] [URI: {locale}/email/verify/{id}/{hash}]

在注册过程中,发送验证邮件时添加 {locale} 出现问题。 正在将数据添加到数据库中。但此后出现以下问题。

[路由:verification.verify] [URI:{locale}/email/verify/{id}/{hash}] 缺少必需的参数。

我认为这将是某种覆盖验证过程的类型。

web.php

Route::group([
  'prefix' => '{locale}', 
  'where' => ['locale' => '[a-zA-Z]{2}'], 
  'middleware' => 'setlocale'], function() {
Auth::routes(['verify' => true]);

Route::get('/home', 'HomeController@index')->name('home');
});

Route::get('/', function () {
    return redirect(app()->getLocale());
});

vendor/laravel/framework/src/Illuminate/Routing/Router.php

$this->get('email/verify/{id}/{hash}', 'Auth\VerificationController@verify')->name('verification.verify');

我知道路由器 {locale} 与路由不匹配。但是如何解决呢?

不要使用 Auth::routes(['verify' => true]);,只需使用 Auth::routes(); 并手动添加这些路由:

Route::get('email/verify', 'Auth\VerificationController@show')->name('verification.notice');
Route::get('email/verify/{id}', 'Auth\VerificationController@verify')->name('verification.verify');
Route::get('email/resend', 'Auth\VerificationController@resend')->name('verification.resend');

Route::group([ 'prefix' => '{locale}', 'where' => ['locale' => '[a-zA-Z]{2}'], 'middleware' => 'setlocale'], function() { 
    Auth::routes();
    Route::get('/home', 'HomeController@index')->name('home'); 
}); 

检查

对于 Laravel 6 和 7,verification.verify 路线是

'email/verify/{id}/{hash}'

如果你有这个,请检查一下,因为对我来说这是一个自定义验证 link

Route::group(['prefix' => '{locale}',  'where' => ['locale' => '[a-zA-Z]{2}'], 'middleware' => 'setlocale'], function() {
    
    Auth::routes();
    Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');

});
Route::get('email/verify', [App\Http\Controllers\Auth\VerificationController::class,'show'])->name('verification.notice');
Route::get('email/verify/{id}', [App\Http\Controllers\Auth\VerificationController::class,'verify'])->name('verification.verify');
Route::post('email/resend', [App\Http\Controllers\Auth\VerificationController::class,'resend'])->name('verification.resend');

重发应该是Post方法! 这适用于 Laravel 8.0

打开您的 verify.blade.php 文件

{{ route('verification.resend') }}

替换为

{{ route('verification.resend', app()->getlocale()) }}