laravel如何路由到同一控制器中的另一个功能 [英] laravel how to route to another function in the same controller

查看:129
本文介绍了laravel如何路由到同一控制器中的另一个功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个注册控制器,当用户成功注册后,我想将他路由到他的个人资料页面.

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)

注册时,用户触发save功能.所以我的问题是如何将他路由到具有id的show函数?

when registering, the user fires the save function. so my question is how to route him to the show function with the id ?

我可以制作view:make(),但是我不想直接将他路由到视图,但是首先我想将他路由到show函数来做一些事情,然后在show函数中我做view.make

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

推荐答案

您可以使用重定向功能

如果您使用的是命名路由:

If you are using named routes:

return Redirect::route('profile', array($id));

如果不是:

return Redirect::to('user/show/' . $id);

这篇关于laravel如何路由到同一控制器中的另一个功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆