【发布时间】:2017-10-25 20:33:14
【问题描述】:
我希望应用使用类似这样的 URL 结构:
-
/account/johnsmith/photos /account/johnsmith/messages/account/johnsmith/settings/account/joebloggs/photos
因此用户可以添加多个帐户,然后路由组自动选择帐户。
Route::group(['middleware' => 'auth', 'prefix' => 'account/{username}'], function () {
Route::get('/photos', 'PhotosController@index')->name('photos.index');
});
在上面的示例中,我可以访问PhotosController@index 内部的{username} 参数。
有没有办法编写一些中间件来自动获取帐户信息并且组中的所有子路由都可以访问它?或者这是尝试构建它的坏方法吗?
【问题讨论】: