dqzuo0327 2013-12-09 09:05
浏览 27
已采纳

简单的Laravel命名路由

I am using Laravel 4. I am trying to use named route. The following url gives a "Controller method not found" error. I will appreciate any help.

http://example.com/student/1

I understand that route order matters , and the deepest urls are supposed to go first, hence my current route.php looks :

Route::get('student/{id}', array('as'=>'student.practice' , 'uses'=>'StudentsController@practice'));
Route::controller('users', 'UsersController');
Route::controller('students', 'StudentsController');

I have tried changing the order that. It makes no difference.

My StudentController does have a getPractice method.

public function getPractice($id)
{
    return View::make('students.practice')
    ->with('student', Student::find($id));
}
  • 写回答

1条回答 默认 最新

  • dro60731 2013-12-09 09:13
    关注

    Change your route like so:

    Route::get('student/{id}', array('as'=>'student.practice' , 'uses'=>'StudentsController@getPractice'));
    

    It looks like you are trying to use a mixture of RESTful and nonRESTful methods.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部