Support the ongoing development of Laravel.io →
Authentication Laravel

I'm using Laravel 7 and Visual Code. My Logout Controller have a problem but the code work when i run. What's the problem?

<?php namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; use Illuminate\Http\Request; class LogoutController extends Controller { public function __invoke(Request $request) { auth()->logout(); return redirect('/'); } }

Error in my VSCode is

Undefined method 'logout'. intelephense(1013) [18,17]

It's a bug? or my fault? Thankslal

Last updated 3 years ago.
0

Hey!

Nothing to worry about. Your IDE is just not able to find the method event though it's there.

You can also try to logout using the Auth Facade directly like this:

\Auth::logout();

There are a few occurrences where magic methods can not be resolved eg. when they are behind Facades or likewise.

renaldyks liked this reply

1
Solution selected by @renaldyks

Sign in to participate in this thread!

PHPverse

Your banner here too?

Kev renaldyks Joined 19 Oct 2021

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.