문제

I have the following routes set up in my Laravel 4 application:

Route::get('/news', 'NewsController@index');
Route::get('/news/{slug}', 'NewsController@view');

In my NewsController.php file, I have the appropriate actions set up that return views. Now, when I browse to /news, I get an error message like so:

Some mandatory parameters are missing ("slug") to generate a URL for route "get /news/{slug}

and when I browse to /news/test-post it all works fine.

What's weird is that if I comment out the route for /news/{slug} and browse to /news, this error gets thrown:

Unknown action [NewsController@view].

even though the route for /news doesn't touch the view action, it uses index.

도움이 되었습니까?

해결책

Are you sure you haven't defined a RESTful controller routing before? Like:

Route::controller('/news', 'NewsController');

If you have, put the Route::get before the Route::controller. Otherwise I don't really know whats wrong, I couldn't reproduce the error with your setup.

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