2016-04-17 66 views
-1

我正在開發laravel的學校管理系統。我有很多類似的控制器在Laravel爲每個控制器的索引方法創建路由

控制器的工作人員在法指數

class controllerstaff extends controller { 
    public function index{ 
    //here process of staff data 
    } 
} 

//this controller have `Route::get('/', '[email protected]'); 

及其他控制器

class controllerstudent extends controller { 
    public function index{ 
    //here process of student data 
    } 
} 

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

如上不能正常工作。

任何人都可以告訴我如何爲索引方法的每個控制器創建路由。如果我們打包多個路由文件,那麼如何操作它以及如何訪問控制器和表單動作

回答

3

您無法爲每個路由創建相同的URL。對於每一個路線,你需要有不同的URL,例如:

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

您也應該爲您的控制器,而StudentController,而不是controllerstudent。您也可以考慮在創建代碼之前查看Routing documentation - 我相信這可能是正確的方法;)