0
我想在Laravel 5創建嵌套資源控制器航線如..嵌套資源控制器5
/customers/{customer}/modulename/clients/{client}
在應用我開發我有誰在登錄客戶到應用程序,但也是系統管理員。每個客戶都可以選擇多個模塊來使用,而在這些模塊中,有時候會有相同的模型,但他們使用的是不同的控制器。
我已經使用了以下解決方案,但它們存在一些問題。
Route::resource('customers', 'CustomerController');
Route::resource('customers.clients', 'CustomerController');
我不能去在這個解決方案不同的模塊,所以我試圖讓組...
Route::group(['prefix' => 'customers/{customer}', ''], function(){
Route::group(['prefix' => 'module1', ''], function(){
Route::resource('clients', 'Module1\ClientAController');
});
Route::group(['prefix' => 'module2', ''], function(){
Route::resource('clients', 'Module2\ClientBController');
});
});
Route::resource('customers', 'CustomerController');
但路線越來越討厭。在構建菜單層次結構時,以下路線很難創建。
route('customers.{customer}.module1.clients.index');
是它應該是什麼,但我想獲得去...
route('customers.module1.clients.index');
有沒有爲Route::group()
功能我缺少一個選項,或者我可以做一組在路由資源內?或者我應該只是寫出所有不同Route::get
和Route::post
功能與該$options = ['uses' => '...', 'as' => 'customers.module1.clients.*']
爲什麼你不使用'Route :: resource('customer.module.client');'? – Mithredate
我想到了這個解決方案,但我想爲不同的客戶端使用不同的控制器 –