1

In my controller, I have a method to redirect to a route:

return Redirect::route('/management');

This is my routes/web.php:

Route::get('/management', function () {
    return Inertia::render('Management');
});

However, it throws an error saying Route [management] not defined.

1 Answer 1

3

The Redirect::route() method expects a named route, which you have not defined in your routes/web.php file.

In order to use a named route, you need to change your route to:

Route::get('/management', function () {
    return Inertia::render('Management');
})->name('management'); // added

After that, you can redirect to named routes in Inertia like so:

return Redirect::route('management');

Since we're using named routes, and not URLs, you should not include the leading / in your route() call.

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

2 Comments

Can we send data using return Redirect::route() method?
No, it's a redirection, so you can't send data to your response. Depending on your use case, you may be able to use a well defined route that includes parameters, but it's hard to say without knowing the full details of the data you need to send.

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.