mailwolt/app/Livewire/Ui/System/ApiKeyTable.php

35 lines
849 B
PHP

<?php
namespace App\Livewire\Ui\System;
use App\Models\PersonalAccessToken;
use Illuminate\Support\Facades\Auth;
use Livewire\Attributes\Layout;
use Livewire\Attributes\Title;
use Livewire\Component;
#[Layout('layouts.dvx')]
#[Title('API Keys · Mailwolt')]
class ApiKeyTable extends Component
{
public function deleteToken(int $id): void
{
$token = PersonalAccessToken::where('tokenable_id', Auth::id())
->where('tokenable_type', Auth::user()::class)
->findOrFail($id);
$token->delete();
$this->dispatch('notify', type: 'success', message: 'API Key gelöscht.');
}
public function render()
{
$tokens = Auth::user()
->tokens()
->latest()
->get();
return view('livewire.ui.system.api-key-table', compact('tokens'));
}
}