RichardMiracles
RichardMiracles

Reputation: 2152

Redirect a route with parameters in url to another route with these parameters (Laravel)

I have a url and I want make a redirection and I want to keep the url parameters. I'm using the ->with method but it doesn't work.

Example: http://mywebsite.local/product-name-random?select_article=710

I want redirect this url to: http://mywebsite.local/father-category-of-this-product?select_article=710

I'm using this code but it doesn't work:

return redirect()->route('web.custom_url', $father_cathegory->seo->slug)->with('select_article', Input::get('select_article')); 

->with() is not working. Nothing happens.

Im using Laravel 5.5.

Upvotes: 0

Views: 229

Answers (3)

simonecosci
simonecosci

Reputation: 1204

Using ->with() you're flashing the session. You could do something like this:

$to = route('web.custom_url', $father_cathegory->seo->slug) . 
    '?select_article=' . Input::get('select_article');
return redirect()->to($to);

Upvotes: 0

Shailendra Gupta
Shailendra Gupta

Reputation: 1118

you can also use

redirect()->route('web.custom_url',[ $father_cathegory->seo->slug])->withInput();

it will redirect to route with input

Upvotes: 0

user10186369
user10186369

Reputation:

You should try this way:

return Redirect::to('/admin/slider?rdStatus='. $rdStatus);

Upvotes: 1

Related Questions