laravel how to route to another function in the same controller

你。 提交于 2019-12-12 01:57:25

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!