Allow completely deleting a user with all the sites etc.

This commit is contained in:
Ralph J. Smit
2022-08-16 13:20:23 +02:00
parent ae1b41e068
commit dc87d0d415
8 changed files with 168 additions and 57 deletions

View File

@@ -2,9 +2,11 @@
namespace App\Filament\Resources\UserResource\Pages;
use Filament\Pages\Actions;
use App\Actions\User\DeleteUserAction;
use App\Filament\Resources\UserResource;
use Filament\Forms\Components\Toggle;
use Filament\Notifications\Notification;
use Filament\Pages\Actions;
use Filament\Resources\Pages\EditRecord;
class EditUser extends EditRecord
@@ -27,7 +29,25 @@ class EditUser extends EditRecord
})
->visible(fn () => $this->record->hasTwoFactorEnabled())
->requiresConfirmation(),
Actions\DeleteAction::make(),
Actions\Action::make('delete')
->form([
Toggle::make('remove_all_data')
->label(__('Delete all sites, databases, etc.'))
->default(true)
->helperText(__('This will delete all the sites, databases, etc. associated with this user. Sites that belong to multiple users will not be deleted. This action cannot be undone.')),
])
->requiresConfirmation()
->action(function (array $data) {
app(DeleteUserAction::class)->execute($this->getRecord(), $data['remove_all_data']);
Notification::make()
->body(__('User deleted'))
->success()
->send();
$this->redirectRoute('filament.resources.users.index');
})
->color('danger'),
];
}
}