-
-
Notifications
You must be signed in to change notification settings - Fork 60
/
ApiTokensPage.php
48 lines (35 loc) · 1.07 KB
/
ApiTokensPage.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
namespace App\Filament\Pages;
use App\Models\User;
use Filament\Pages\Page;
use Illuminate\Support\Facades\Auth;
use Livewire\Livewire;
class ApiTokensPage extends Page
{
protected static string $view = 'filament.pages.api.api-tokens';
protected static ?string $navigationIcon = 'heroicon-o-key';
protected static ?string $navigationGroup = 'Account';
protected static ?int $navigationSort = 2;
protected static ?string $title = 'API Tokens';
public User $user;
public function mount(): void
{
$this->user = Auth::user();
}
public function createApiToken(string $name, array $permissions): void
{
$this->user->createToken($name, $permissions);
}
public function deleteApiToken(string $name): void
{
$this->user->tokens()->where('name', $name)->first()->delete();
}
public function getHeading(): string
{
return static::$title;
}
public static function shouldRegisterNavigation(): bool
{
return config('filament-jetstream.show_api_token_page');
}
}