logout laravel code example

Example 1: laravel token logout

public function logout (Request $request) {
$accessToken = auth()->user()->token();
$token= $request->user()->tokens->find($accessToken);
$token->revoke();
return response(['message' => 'You have been successfully logged out.'], 200);
}

Example 2: laravel get auth user id

// Get the currently authenticated user's ID...
$id = Auth::id();

Example 3: laravel auth

composer require laravel/ui

php artisan ui vue --auth

npm install && npm run dev

Example 4: laravel 8 make:auth

composer require laravel/ui --dev
php artisan ui vue --auth

Example 5: Auth log out laravel

Auth::logout();

Example 6: laravel auth

// Laravel 5.x
php artisan make:auth

Tags:

Php Example