58 lines
2.0 KiB
PHP
58 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Users\Pages;
|
|
|
|
use App\Filament\Resources\Users\UserResource;
|
|
use Filament\Actions\Action;
|
|
use Filament\Actions\CreateAction;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Resources\Pages\ListRecords;
|
|
use Filament\Schemas\Components\Section;
|
|
|
|
class ListUsers extends ListRecords
|
|
{
|
|
protected static string $resource = UserResource::class;
|
|
|
|
protected function getHeaderActions(): array
|
|
{
|
|
return [
|
|
Action::make('inviteUser')
|
|
->label('Einladen')
|
|
->icon('phosphor-envelope')
|
|
->form([
|
|
Section::make('Jemanden einladen')
|
|
->icon('lucide-user')
|
|
->description('Nur mit dieser Einladung können sich weitere Benutzer bei diesem Konto registrieren.')
|
|
->schema([
|
|
TextInput::make('email')
|
|
->label('E-Mail')
|
|
->prefixIcon('phosphor-envelope')
|
|
->email()
|
|
->required()
|
|
->belowContent('Die Einladung ist 12 Stunden gültig.'),
|
|
]),
|
|
])
|
|
->action(function ($data) {
|
|
$invitation = Invitation::create([
|
|
'knoto_id' => auth()->user()->konto_id,
|
|
'email' => $data['email'],
|
|
]);
|
|
|
|
// @todo Add email sending here
|
|
|
|
Notification::make('invitedSuccess')
|
|
->body('Der Benutzer wurde erfolgreich eingelanden!')
|
|
->success()->send();
|
|
}),
|
|
CreateAction::make()
|
|
->icon('phosphor-file-plus')
|
|
->createAnother(false)
|
|
->mutateDataUsing(function (array $data): array {
|
|
$data['konto_id'] = auth()->user()->konto_id;
|
|
|
|
return $data;
|
|
}),
|
|
];
|
|
}
|
|
}
|