0

我正在使用 Laravel 4。我正在尝试使用命名路由。以下 url 给出了“找不到控制器方法”错误。我将不胜感激。

http://example.com/student/1

我知道路由顺序很重要,最深的 url 应该首先出现,因此我当前的 route.php 看起来:

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

我试过改变顺序。没什么区别。

我的 StudentController 确实有一个 getPractice 方法。

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

1 回答 1

1

像这样改变你的路线:

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

看起来您正在尝试混合使用 RESTful 和非 RESTful 方法。

于 2013-12-09T17:13:31.583 回答