2017-08-17 48 views
0

我有一個控制器具有多個功能與相同的路由器,所以我得到錯誤異常。 請指導我這個錯誤訪問Laravel中使用相同路由器的單控制器的多個功能

Route::group(['prefix' => 'admin', 'middleware' => ['auth', 'admin']], function() 
{ 
    Route::get('/dashboard','[email protected]'); 
    Route::get('/dashboard','[email protected]'); 
}); 
+2

對於單一路線,您無法調用多種不同的方法 – adamyi

+0

您期望它做什麼? –

回答

1

你不能,解決的辦法是:

Route::group(['prefix' => 'admin', 'middleware' => ['auth', 'admin']], function() 
{ 
    Route::get('/chart','[email protected]'); 
    Route::get('/dashboard','[email protected]'); 
}); 

或者你可以調用多個功能使用同一個網址,一個以「get」方法,以及其他與「後」,例如:

Route::group(['prefix' => 'admin', 'middleware' => ['auth', 'admin']], function() 
{ 
    Route::post('/dashboard','[email protected]'); 
    Route::get('/dashboard','[email protected]'); 
}); 

Route::post()後,才提交表單與方法後訪問。

+0

感謝您的建議 –