<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Session;

class LogoutController extends Controller
{
    /**
     * Log out account user.
     *
     * @return \Illuminate\Routing\Redirector
     */
    public function perform()
    {
        // Clear user session info before logout
        if (Auth::check()) {
            $user = Auth::user();
            $user->clearSession();
        }

        Session::flush();

        Auth::logout();

        return redirect('login');
    }
}
