Passing parameter to controller from route in laravel
Posted
by
bretterer
on Stack Overflow
See other posts from Stack Overflow
or by bretterer
Published on 2012-09-28T21:09:50Z
Indexed on
2012/09/28
21:37 UTC
Read the original article
Hit count: 386
Given the following route
Route::get('groups/(:any)', array('as' => 'group', 'uses' => 'groups@show'));
And the URL I would like to use,
http://www.example.com/groups/1
I would like to be able to use the (:any)
value in my controller.
My controller looks like
class Groups_Controller extends Base_Controller {
public $restful = true;
public function get_show($groupID) {
return 'I am group id ' . $groupID;
}
}
How is this possible to do? I have tried a few things including the following
Route::get('groups/(:any)', array('as' => 'group', 'uses' => 'groups@show((:1))'));
but it did not work.
UPDATE
Anytime I try to pass in the arguments as show above i get a 404 error.
Thanks for the help!
© Stack Overflow or respective owner