Skip to content

konnco/filament-safely-delete

Repository files navigation

Screenshot of Login

Filament Confirm Delete

FILAMENT 2.x Packagist Downloads

Code Styles run-tests

This plugin is intended for those of you who are worried about your data being accidentally deleted.

Installation

You can install the package via composer:

composer require konnco/filament-safely-delete

Usage

import the actions into the Resource page

use Konnco\FilamentSafelyDelete\Tables\Actions\RevertableDeleteAction;

class PostResource extends Resource
{
    public static function table(Table $table): Table
    {
        return $table
            ->columns([
                Tables\Columns\TextColumn::make('title'),
                Tables\Columns\TextColumn::make('slug'),
                Tables\Columns\TextColumn::make('body'),
            ])
            ->filters([
                //
            ])
            ->actions([
                Tables\Actions\EditAction::make(),
                DeleteAction::make()
                    ->usingField('title')
            ])
            ->bulkActions([
                Tables\Actions\DeleteBulkAction::make(),
            ]);
    }
}

Undo Delete

You can also use to delete undo in your resource.

use Konnco\FilamentSafelyDelete\Tables\Actions\RevertableDeleteAction;

class PostResource extends Resource
{
    public static function table(Table $table): Table
    {
        return $table
            ->columns([
                Tables\Columns\TextColumn::make('title'),
                Tables\Columns\TextColumn::make('slug'),
                Tables\Columns\TextColumn::make('body'),
            ])
            ->filters([
                //
            ])
            ->actions([
                Tables\Actions\EditAction::make(),
                RevertableDeleteAction::make()
            ])
            ->bulkActions([
                Tables\Actions\DeleteBulkAction::make(),
            ]);
    }
}

and implementing HasRevertableRecord traits in your ListRecords

use Konnco\FilamentSafelyDelete\Pages\Concerns\HasRevertableRecord;

class ListBlogPosts extends ListRecords
{
    use HasRevertableRecord;

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Contributors

Franky
Franky So
Herbert
Herbert Maschke
abangijal/
abangijal
frankyso
Franky So
thyseus
Herbert Maschke
ijalnasution
Abangijal