Question

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));
}
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top