laravel-routing如何将其转换为资源

时间:2017-02-28 01:30:39

标签: laravel

Route::get('/teacher', [
   'uses' => 'AppController@getTeacherPage',
   'as' => 'teacher',
   'middleware' => 'roles',
   'roles' => ['Admin', 'Teacher']
]);

如何将其转换为资源

我试过像

这样的东西
Route::resource('teacher',TeacherController, [
   'uses' => 'TeacherController@index',
   'as' => 'teacher',
   'middleware' => 'roles',
   'roles' => ['Admin', 'Teacher']
]);

1 个答案:

答案 0 :(得分:0)

Route::resource('teachers',TeacherController, [
   'names' => [
       'teachers' => 'teachers.index',
       'teacher' => 'teachers.show'
   ],
   'middleware' => 'roles',
   'roles' => ['Admin', 'Teacher']
]);

将匹配index()show($id)个功能。