Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Khin Zin Zin Thinn's avatar

BadMethodCallException Method Illuminate\Routing\Route::with does not exist.

I am now trying to create the log out button and this error pops up. I already spent some time on it and it is still not resolved. Please suggest to me what to do to solve this. Thanks. (FYI: I have installed the Jetstream for authentication)

Codes from Blade button

<li class="dropdown-footer">
    <a href="{{ route('user.logout') }}"> <i class="mdi mdi-logout"></i> Log Out </a>
</li>

Codes from Route

Route::get('/user/logout', [UserController::class, 'logout'])->with('user.logout');

Codes from Controller

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class UserController extends Controller
{
    public function __construct() {
        $this->middleware(['auth']);
    }

    public function logout() {
        Auth::logout();

        return redirect()->route('login')->with('success', 'Logged Out');
    }
}
0 likes
4 replies
Snapey's avatar

Logout should always be a POST method. Why did you change it if you used Jetstream ?

anyway

return redirect(route('login')->with('success', 'Logged Out');
Khin Zin Zin Thinn's avatar

I am adding custom html, css template to my project and just wanted to enable the logout button of it. I actually watched a tuto video on udemy that he does the same way but with no error. I also tried changing that to the 'post' method and it doesn't work. I included the route('login') inside redirect() and it still doesn't work. Please guide me what I should do next.

jlrdw's avatar

See example of how Taylor set up log out in laravel, he posts the form with JavaScript.

Please or to participate in this conversation.