-
-
Notifications
You must be signed in to change notification settings - Fork 268
Expand file tree
/
Copy pathPasskeys.php
More file actions
63 lines (51 loc) · 1.71 KB
/
Passkeys.php
File metadata and controls
63 lines (51 loc) · 1.71 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
declare(strict_types=1);
namespace App\Livewire;
use Filament\Actions\Action;
use Filament\Actions\Concerns\InteractsWithActions;
use Filament\Actions\Contracts\HasActions;
use Filament\Notifications\Notification;
use Filament\Schemas\Concerns\InteractsWithSchemas;
use Filament\Schemas\Contracts\HasSchemas;
use Illuminate\View\View;
use Spatie\LaravelPasskeys\Livewire\PasskeysComponent;
final class Passkeys extends PasskeysComponent implements HasActions, HasSchemas
{
use InteractsWithActions;
use InteractsWithSchemas;
public function confirmDelete(int $passkeyId): void
{
$this->mountAction('deleteAction', ['passkey' => $passkeyId]);
}
public function deleteAction(): Action
{
return Action::make('deleteAction')
->label(trans('passkeys.delete'))
->color('danger')
->requiresConfirmation()
->action(fn (array $arguments) => $this->deletePasskey((int) $arguments['passkey']));
}
public function deletePasskey(int $passkeyId): void
{
$this->currentUser()->passkeys()->findOrFail($passkeyId);
parent::deletePasskey($passkeyId);
Notification::make()
->title(trans('passkeys.deleted_notification_title'))
->success()
->send();
}
public function storePasskey(string $passkey): void
{
parent::storePasskey($passkey);
Notification::make()
->title(trans('passkeys.created_notification_title'))
->success()
->send();
}
public function render(): View
{
return view('passkeys.livewire.passkeys', data: [
'passkeys' => $this->currentUser()->passkeys()->get(),
]);
}
}