<?php

namespace App\Http\Livewire\Pages\Auth;

use Livewire\Component;

use Illuminate\Http\Request;

class Logout extends Component
{   
    public function logout(Request $request)
    {
        if(!request()->isMethod('POST')) {
            return;
        }

        \Illuminate\Support\Facades\Auth::logout();
        
        $request->session()->invalidate();

        $request->session()->regenerateToken();

        redirect()->route('login')->with(['message' => 'Session Terminated']);
    }

    public function render()
    {
        return view('livewire.pages.auth.logout');
    }
}
