Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

THIS IS A QUESTION FOR LARAVEL 3

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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
343 views
Welcome To Ask or Share your Answers For Others

1 Answer

You don't need anything special for adding paramaters. Just like you had it.

Route::get('groups/(:any)', array('as' => 'group', 'uses' => 'groups@show'));


class Groups_Controller extends Base_Controller {

    public $restful = true;    

    public function get_show($groupID) {
        return 'I am group id ' . $groupID;
    }  


}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...