Php Laravel 8:Routegroup don'中带有参数的路由;行不通
我在grouproute中遇到了laravel本地化和路由问题 我尝试访问此url: http://localhost/logiluxe/public/en/games_giveaways/1 我的路线:Php Laravel 8:Routegroup don'中带有参数的路由;行不通,php,laravel,laravel-8,Php,Laravel,Laravel 8,我在grouproute中遇到了laravel本地化和路由问题 我尝试访问此url: http://localhost/logiluxe/public/en/games_giveaways/1 我的路线: Route::group(['middleware' => ['setlocale'],'prefix' => '{locale}', 'where' => ['locale' => '[a-zA-Z]{2}']], function() { Auth::rou
Route::group(['middleware' => ['setlocale'],'prefix' => '{locale}', 'where' => ['locale' => '[a-zA-Z]{2}']], function() {
Auth::routes();
Route::get('/games_giveaways/{id}', [GameGiveawayController::class, 'show'])->name('games_giveaways.show');
});
我的中间件:
public function handle(Request $request, Closure $next) {
if(session()->has('locale')){
app()->setLocale(session()->get('locale'));
//Carbon::setLocale(session()->get('locale'));
} elseif ($request->segment(1)) {
app()->setLocale($request->segment(1));
} else {
app()->setLocale('en');
}
return $next($request);
}
错误:
Missing required parameter for [Route: games_giveaways.show] [URI: {locale}/games_giveaways/{id}]
[Missing parameter: id]. (View: C:\wamp64\www\logiluxe\resources\views\layouts\app.blade.php)
看起来我不能在routegroup中有带参数的路由。您的错误在balde中,而不是路由声明本身 在刀片服务器中的某个位置,您正在通过别名调用路由,而不使用ID参数
//change this in your blade
route('games_giveaways.show', ['locale' => 'en']);
//to
route('games_giveaways.show', ['locale' => 'en', 'id' => 1]);
是我干的。我的错误与最初的帖子完全相同。@Shäninjah你在其他地方还有它。使用grepwin/grep等工具搜索
games\u赠品。在刀片/code中显示我只有一次对我的路线的调用:route('games\u赠品.show',['locale'=>en','id'=>1])代码>我认为问题来自于在带有参数(locale)的组路由中有一个带有参数(id)的路由。即使当我在浏览器中使用直接url写入来访问我的页面时,我也有这个错误,我已经定义了区域设置和id<代码>路线参数区域设置:en id:1