33 lines
701 B
PHP
33 lines
701 B
PHP
<?php
|
|
|
|
namespace App\Livewire;
|
|
|
|
use Livewire\Component;
|
|
use App\Services\ApiService;
|
|
use Illuminate\Support\Facades\Session;
|
|
|
|
class Logout extends Component
|
|
{
|
|
protected $apiService;
|
|
|
|
public function boot(ApiService $apiService)
|
|
{
|
|
$this->apiService = $apiService;
|
|
}
|
|
|
|
public function logout()
|
|
{
|
|
try {
|
|
if ($this->apiService->logout()) {
|
|
return redirect()->route('login')->with('success', 'Logged out successfully.');
|
|
}
|
|
} catch (\Exception $e) {
|
|
return redirect()->back()->with('error', $e->getMessage());
|
|
}
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.logout');
|
|
}
|
|
} |