문제

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));
}
도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top