2016-10-26 1 views
0

ルートグループ内の異なる名前空間を持つコントローラーを使用できますか?ルートグループ内の異なる名前空間を持つコントローラーを使用できますか?

Route::group(['prefix' => 'dashboard', 'namespace' => 'admin'], function() { 
    Route::get('/', ['namespace'=>'Controllers','uses'=>'[email protected]']); 
    Route::get('posts', '[email protected]'); 
}); 
+0

「使用」=>「\\ NameSpace \\ Controller @ function」はあなたのために働くはずです。 –

答えて

0

@TimLewisはコメントに記載されているように可能です。

次は動作するはずです(SiteControllerのための完全な名前空間がApp\Http\Controllersであると仮定):

Route::group(['prefix' => 'dashboard', 'namespace' => 'admin'], function() { 
    Route::get('/', '\App\Http\Controllers\[email protected]'); 
    Route::get('posts', '[email protected]'); 
}); 

しかし、それはルートを分割する方が理にかなって:

Route::group(['prefix' => 'dashboard'], function() { 

    Route::get('/', '[email protected]'); 

    Route::group(['namespace' => 'admin'], function() { 
     Route::get('posts', '[email protected]'); 
    }); 
}); 

・ホープ、このことができます!

+0

ありがとう非常にマッチ –

関連する問題