问题
I have a controller for registering, when the user register successfully I would like to route him to his profile page.
In user controller I have these functions:
save
show($id)
when registering, the user fires the save function. so my question is how to route him to the show function with the id ?
I could make view:make() but I don't want to route him directly to the view but first I want to route him to the show function to do some stuff and then in the show function I do view.make
回答1:
you can use Redirect functions
If you are using named routes:
return Redirect::route('profile', array($id));
If not:
return Redirect::to('user/show/' . $id);
回答2:
If you want to route him to the show() method from the save() method, you can simply return $this->show($id); assuming you have his id.
You could even add extra variables to the view if you wish with return $this->save($id)->with('some_data', $some_data);
来源:https://stackoverflow.com/questions/24286015/laravel-how-to-route-to-another-function-in-the-same-controller