This is probable a very simple one.
I have a function for the index that either lists everything or a specific item based on an optional parameter passed to it.
I have this route for the controller:
Route::controller('movies/(:any)');
I want to redirect it to the movies index function with the parameter in place.
I dont want people to have to type:
http://www.site.com/movies/index/2
but instead
http://www.site.com/movies/2
I have tried a Question mark in the any array and a ‘closure’ function (I think thats the right terminology) to allow me to redirect.
The closure attempt looked like this:
Route::controller('movies/(:any?)',function($id){
return Redirect::to("movie/index/$id");
});
This gives me a 404 error.
Am I doing it right?
You dont want to distiquish that on your Route, let the controller decide what to do.
Your Route:
Your Controller: