我有一条路线
Route::get('/category/{categorySlug}', 'CategoryController@showPage')->name('category.show');
是否可以从 $request 实例中获取 categorySlug?我的意思是 $request->get('categorySlug') 因为我在那里没有看到那个参数。
最佳答案
可以通过请求中的路由获取参数:
$request->route('parameter_name')
在这种情况下:
$request->route('categorySlug')
你可以得到所有的参数作为数组:
$request->route()->parameters
关于Laravel 从请求实例获取路由参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64041142/