0
我試圖減少我的路由文件的大小並重新使用命名的路由。我有兩個獨立的區域經過驗證並擁有自己的專用路線,但是,它們都共享很多其他路線。在多個前綴之間共享路由
Route::group(['middleware' => 'web'], function() {
/**
* Author routes.
*/
Route::group(['prefix' => 'author', 'middleware' => 'auth'], function() {
Route::get('/', ['as' => 'dashboard', 'uses' => '[email protected]']);
// ...various routes unique to authors...
Route::any('posts/data', ['as' => 'posts.data'])->uses('[email protected]');
Route::get('posts/{account?}', ['as' => 'posts.show'])->uses('[email protected]');
Route::get('posts/{post}/delete', ['as' => 'posts.delete'])->uses('[email protected]');
Route::resource('posts', 'PostsController', ['parameters' => 'singular']);
// ...lots more routes like the above shared with reviewers...
});
/**
* Reviewer routes.
*/
Route::group(['prefix' => 'reviewer', 'middleware' => 'auth'], function() {
Route::get('/', ['as' => 'dashboard', 'uses' => '[email protected]']);
// ...various routes unique to reviewers...
Route::any('posts/data', ['as' => 'posts.data'])->uses('[email protected]');
Route::get('posts/{account?}', ['as' => 'posts.show'])->uses('[email protected]');
Route::get('posts/{post}/delete', ['as' => 'posts.delete'])->uses('[email protected]');
Route::resource('posts', 'PostsController', ['parameters' => 'singular']);
// ...lots more routes like the above shared with authors...
});
});
我還需要審閱去3210做的所有職位相關的活動和作者去example.com/author/posts
。
我怎樣才能使這個更少冗長?
我不明白,什麼是有不同的URI去完全相同的控制點? – PeterPan666
試圖創建一個單獨的審閱者和作者區。 – eComEvo
是的,但如果控制器是相同的,我真的不明白這一點.. – PeterPan666