deroccha
deroccha

Reputation: 1183

Redirect to a resource route with parameters Laravel

I try to redirect to a resource route with paramateres in my laravel controller

Redirect::route('users.show', array('user'=> $user->account_id));

but the parameter is never getting passed through.

What I'm doing wrong?

Upvotes: 1

Views: 3330

Answers (4)

Ashik Iqbal
Ashik Iqbal

Reputation: 11

You have to add "return" keyword before "redirect". Try like this

return redirect()->route('users.show', $user->account_id);

Upvotes: 0

Parth Vora
Parth Vora

Reputation: 4114

It should work. May be you are passing a null value.

Check the value of $user->account_id using dd($user->account_id);

Upvotes: 0

user8203594
user8203594

Reputation:

You can Try like this

redirect()->route('users.show', ['user'=> $user->account_id]);

Upvotes: 2

Goolishka
Goolishka

Reputation: 250

Try to use this:

Redirect::route('users.show', ["user" => $user->account_id]);

Upvotes: 0

Related Questions