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

Rretzko's avatar
Level 15

Call to undefined method destroy() on application logout.

Hi - When I log out of my application I get the following error: Call to undefined method Filament\Http\Controllers\Auth\LogoutController::destroy(). Filament's logout controller is an invokable model without a destroy method, so I don't know what is generating this error. Thanks for any thoughts on this!

<?php

namespace Filament\Http\Controllers\Auth;

use Filament\Facades\Filament;
use Filament\Http\Responses\Auth\Contracts\LogoutResponse;

class LogoutController
{
    public function __invoke(): LogoutResponse
    {
        Filament::auth()->logout();

        session()->invalidate();
        session()->regenerateToken();

        return app(LogoutResponse::class);
    }
}
0 likes
2 replies
LaryAI's avatar
Level 58

It seems like your application is trying to call a destroy method on the LogoutController, which does not exist. This could be happening because of a misconfigured route or a custom override that is incorrectly implemented.

First, ensure that your logout route is correctly pointing to the __invoke method of the LogoutController. Your route definition should look something like this:

use Filament\Http\Controllers\Auth\LogoutController;

// ...

Route::post('/logout', LogoutController::class)->name('logout');

This route definition uses the LogoutController as an invokable controller, which means when the route is hit, Laravel will call the __invoke method on the LogoutController.

If you have overridden the logout functionality somewhere else in your application, such as in a middleware or another controller, make sure that you are not accidentally calling a destroy method on the LogoutController.

Additionally, check your application's middleware, event listeners, or any other custom logic that might be hooked into the logout process. There might be a piece of code that is trying to call destroy on the controller.

If you are using any third-party packages or have published and modified any authentication scaffolding, double-check those files to ensure there isn't a call to a non-existent destroy method.

If you have overridden the LogoutResponse contract, ensure that the implementation is correct and does not expect a destroy method on the LogoutController.

Lastly, clear your route cache to make sure that the application is using the latest route definitions:

php artisan route:clear

If none of these suggestions solve the issue, you may need to provide more context or code from your application for a more precise diagnosis.

Rretzko's avatar
Rretzko
OP
Best Answer
Level 15

In case anyone else runs into this, I added:

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

        return view('welcome');
    }

to the Filament Logout controller as a successful workaround to the problem. This will need to be recreated if I upgrade Filament in the future.

Please or to participate in this conversation.