Anastasie Laurent
Anastasie Laurent

Reputation: 1179

laravel how to route to another function in the same controller

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

Upvotes: 2

Views: 9403

Answers (2)

Steve
Steve

Reputation: 20469

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);

Upvotes: 4

user1669496
user1669496

Reputation: 33068

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);

Upvotes: 2

Related Questions