1

Purpose: to redirect a specific route with an array value. I am not able to use View::make in my situation, which causes problem.

$value = 'Sarah';

$array_param = array(
   '1' => 'a',
   '2' => 'b'
);

return Redirect::route('myroute', array(
   'name' => $value
));

Above is cool. But i cannot use $array_param with redirect route, which expects a string parameter, but i'm sending an array variable. Alternative way?

return Redirect::route('myroute', array(
   'name' => $value,
   'parameter' => $array_param
));

--update--

Route::post('myroute/{name}/{array_param}', array(
        'as' => 'myroute',
        'uses' => 'mycontroller@mymethod'
    ));
2
  • What is the route definition for myroute? Commented Feb 12, 2016 at 9:53
  • 3
    1. You can't use array route parameters only strings. 2. You should not redirect to a POST route, period. You should separate your GET/POST logic in such a way that redirects occur only towards GET routes. If you provide more information about the target functionality I can suggest a different approach. Commented Feb 12, 2016 at 10:03

1 Answer 1

2

What the version of Laravel do you have?

The code below works for me correctly on laravel 5.1. Maybe it'll help you.

public function store(Request $request)
{
    $item = Item::find(1); // an example
    return redirect()->route('item.show', ['id' => $item->id]);
}

and yes, the redirect to the post route looks very incorrect. Please try to use the redirect only to the GET routes.

Sign up to request clarification or add additional context in comments.

1 Comment

will let you know when i give it a try

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.