ApiJ/app/Http/Controllers/Api/Auth/LogoutController.php

20 lines
436 B
PHP

<?php
namespace App\Http\Controllers\Api\Auth;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
class LogoutController extends Controller
{
//Очишаем токен
public function __invoke(Request $request): \Illuminate\Http\JsonResponse
{
$request->user()->token()->revoke();
return response()->json([
'message' => 'You are successfully logged out',
]);
}
}