1
votes

In a controller I'm calling the redirect helper to change the page with a named route, and i need to pass a parameter to it.

Base on the laravel documentation I did this:

return redirect()->route('named.route', ['id_element' => 1]);

Which should return page/{id_element} according to the documentation

But is actually doing page?id_element=1

Since I'm using page/{id_element} in the router it returns an error saying that there is no route to support it.

May I be doing something wrong? What is it?

I'm using Laravel 6.x

1

1 Answers

1
votes

You need to run the following command in your terminal:

php artisan route:list

This will provide you with a list of your registered routes, their names and the parameter it expects to receive.

For example, if you see this:

/page/{page}

Your method would need to be:

return redirect()->route('named.route', ['page' => 1]);