2016-04-17 6 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を見てみるとよいかもしれません - 正しい方法かもしれません;)