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
.
CodePudding user response:
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.