3

I have created a small application in Laravel 8. Everything is fine, but when I wanted to configure the cache I had an error that one route has the same name as another.

Reviewing the routes I found duplicate named routes, but since I'm new to Laravel, I don't know how to solve this problem. I do not know what to do to have two routes with the same name I hope you can guide me a bit.

Screenshot output of php artisan route:list

John Kary
  • 6,703
  • 1
  • 24
  • 24
Edu
  • 33
  • 1
  • 3
  • Why do you want to have two routes with same name? if you used `route('routeName')` how laravel will know which action to dispatch. Rename the route names will solve the issue. Did you try to give each route a different name? – ibra Apr 16 '21 at 18:32
  • 2
    Those routes were generated when you installed the laravel authentication package. As I'm new to this, I don't know what happened. I realized how much I wanted to optimize laravel, it's as if I had two authentication packages. Because those routes cannot be found routes/wep.php – Edu Apr 16 '21 at 21:41

2 Answers2

1

Just override the laravel auth routes

Route::post('password/email', [
    'as' => 'laravel.password.email',
    'uses' => 'App\Http\Controllers\Auth\ForgotPasswordController@sendResetLinkEmail'
]);

Route::get('password/reset', [
    'as' => 'laravel.password.request',
    'uses' => 'App\Http\Controllers\Auth\ForgotPasswordController@showLinkRequestForm'
]);

But dont forget to change the old route names

ibra
  • 390
  • 3
  • 13
0

Since Laravel 7, applications usually call Auth::routes(); in their routes/web.php file. This registers routes defined by package laravel/ui for various user authentication features.

Search your application's route files in routes/*.php for routes mentioned in the error message, like password.email and password.request.

Rename your custom routes to a different route name, then update that route name throughout your application code.

John Kary
  • 6,703
  • 1
  • 24
  • 24