title: Laravel Error: Unable to prepare route [login] for serialization
body: <p>I'm getting a Laravel error when trying to clear the routes cache:
  Unable to prepare route <code>login</code> for serialization. Another route has already been assigned the name <code>auth.login</code>.
  I have two auth routes:</p>
  <pre><code>Route::get('login', [LoginController::class, 'showLoginForm'])-&gt;name('auth.login')-&gt;middleware('web');
  Route::post('login', [AuthController::class, 'authenticate'])-&gt;name('auth.login');
  </code></pre>
  <p>I know the error is there because there are two routes with the same name. But if I remove the name from the POST route, when I go to the login screen URL, I get a 405 Method not allowed error. This is very strange because the POST route is only used when I type the credentials and click the Login button, not when I go to the login screen URL. Everything works fine with the same names in both routes, but that doesn't make sense.</p>
  <p><code>showLoginForm</code> method is a default method.
  authenticate method is a custom method:</p>
  <pre><code>public function authenticate(Request $request)
  {
      $credentials = $request-&gt;only('email', 'password');
      if (Auth::attempt($credentials)) {
          $user = User::where('email', $request-&gt;email)-&gt;firstOrFail();
          session()-&gt;regenerate();
          $user = Auth::user();
          if (session('saved') == null) {
              Session::put('email', $request-&gt;email);
              Session::put('password', $request-&gt;password);
          }
  
          return redirect()-&gt;intended(route('home'));
      }
  
      return back()-&gt;withErrors([
          'email' =&gt; 'The provided credentials do not match our records.',
      ]);
  }
  </code></pre>