logout laravel 8 api 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 auth

composer require laravel/ui

php artisan ui vue --auth

npm install && npm run dev

Example 3: laravel auth

//laravel 8.x
//for bootstrap scafolding
php artisan ui bootstrap --auth

Example 4: authentication in laravel tutorial

laravelAuth

Tags:

Php Example