PHPackages                             martinpetricko/filament-restore-or-create - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. martinpetricko/filament-restore-or-create

ActiveLibrary[Database &amp; ORM](/categories/database)

martinpetricko/filament-restore-or-create
=========================================

FilamentPHP package that adds ability to check for similar deleted records and restore them instead of creating new ones.

2.1.0(1mo ago)112.3k↓11.5%4[1 PRs](https://github.com/MartinPetricko/filament-restore-or-create/pulls)MITPHPPHP ^8.2CI passing

Since Apr 23Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/MartinPetricko/filament-restore-or-create)[ Packagist](https://packagist.org/packages/martinpetricko/filament-restore-or-create)[ Docs](https://github.com/martinpetricko/filament-restore-or-create)[ GitHub Sponsors](https://github.com/MartinPetricko)[ RSS](/packages/martinpetricko-filament-restore-or-create/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (18)Versions (8)Used By (0)

Filament Restore or Create
==========================

[](#filament-restore-or-create)

[![Latest Version on Packagist](https://camo.githubusercontent.com/6244ffc90d7b73f87a4281ec81157cc0026137c4e9fa778ab71a9a6fbc30ad2d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d617274696e7065747269636b6f2f66696c616d656e742d726573746f72652d6f722d6372656174652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/martinpetricko/filament-restore-or-create)[![GitHub Tests Action Status](https://camo.githubusercontent.com/88ae5bcfdb89ff9dc14465f21970ca08bb46f476fd4f21964648198862d9420d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d617274696e7065747269636b6f2f66696c616d656e742d726573746f72652d6f722d6372656174652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/martinpetricko/filament-restore-or-create/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/9c68aaf3c164d2e3eb4a1a843e96cbe1bb6cd4d76e71a39513481ebc59e254c2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d617274696e7065747269636b6f2f66696c616d656e742d726573746f72652d6f722d6372656174652f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/MartinPetricko/filament-restore-or-create/actions?query=workflow%3A%22Fix+PHP+Code+Styling%22branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/039ad28043128e72bc7bf1693d37dfa4fcaf4b32575e1b9087bdf669c2381c22/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d617274696e7065747269636b6f2f66696c616d656e742d726573746f72652d6f722d6372656174652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/martinpetricko/filament-restore-or-create)

Restore or Create is a FilamentPHP plugin that helps prevent duplicate records by detecting and restoring soft-deleted models when similar data is submitted via a create form.

Features
--------

[](#features)

- Detects similar soft-deleted records before creating a new one.
- Displays a modal with details and an option to restore the deleted record.
- Fully customizable detection, display, and behavior logic.

Installation
------------

[](#installation)

Install via Composer:

```
composer require martinpetricko/filament-restore-or-create
```

Optionally, publish the translation files:

```
php artisan vendor:publish --tag="filament-restore-or-create-translations"
```

Usage
-----

[](#usage)

Add `CheckDeleted` trait to your resource's `CreateRecord` page:

```
use MartinPetricko\FilamentRestoreOrCreate\Concerns\CreateRecord\CheckDeleted;

class CreateUser extends CreateRecord
{
    use CheckDeleted;

    protected static string $resource = UserResource::class;
}
```

Customization
-------------

[](#customization)

### Attributes to check

[](#attributes-to-check)

Define which fields should be used to detect similar deleted records:

```
protected function checkDeletedAttributes(): array
{
    return ['name', 'email', 'phone'];
}
```

### Custom Query Logic

[](#custom-query-logic)

Override the default query to define your own matching logic:

```
protected function checkDeletedModel(array $data): ?Model
{
    return static::getResource()::getEloquentQuery()
        ->whereLike('name', '%' . $data['name'] . '%')
        ->onlyTrashed()
        ->latest()
        ->first();
}
```

### Modal Display Fields

[](#modal-display-fields)

Choose which attributes to show in the confirmation modal:

```
protected function showDeletedAttributes(): ?array
{
    return ['name', 'email', 'phone', 'address', 'deleted_at'];
}
```

### Restore Notification

[](#restore-notification)

Customize the notification shown after a record is restored:

```
protected function getRestoredNotification(): ?Notification
{
    return Notification::make()
        ->success()
        ->title('Restored');
}
```

### Redirect After Restore

[](#redirect-after-restore)

Control where the user is redirected after restoring:

```
protected function getRestoreRedirectUrl(Model $record): string
{
    /** @var class-string $resource */
    $resource = static::getResource();

    if ($resource::hasPage('edit') && $resource::canEdit($record)) {
        return $resource::getUrl('edit', ['record' => $record]);
    }

    return $resource::getUrl();
}
```

Advanced Integration
--------------------

[](#advanced-integration)

If you override `beforeCreate`, ensure the restore behavior is still called:

```
class CreateUser extends CreateRecord
{
    use CheckDeleted {
        beforeCreate as checkDeletedBeforeCreate;
    }

    protected function beforeCreate(): void
    {
        $this->checkDeletedBeforeCreate();

        // Your custom logic
    }
}
```

Testing
-------

[](#testing)

```
composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](.github/SECURITY.md) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Martin Petricko](https://github.com/MartinPetricko)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance89

Actively maintained with recent releases

Popularity30

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 57.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~112 days

Total

4

Last Release

54d ago

Major Versions

1.x-dev → 2.0.02025-06-19

### Community

Maintainers

![](https://www.gravatar.com/avatar/db681d8ae9e45ba4eb11da5407129930a1cfdc321a7f76f3ab5a3a4fb7a2146d?d=identicon)[MartinPetricko](/maintainers/MartinPetricko)

---

Top Contributors

[![MartinPetricko](https://avatars.githubusercontent.com/u/39132866?v=4)](https://github.com/MartinPetricko "MartinPetricko (15 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (7 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (3 commits)")[![grafst](https://avatars.githubusercontent.com/u/8471055?v=4)](https://github.com/grafst "grafst (1 commits)")

---

Tags

createfilamentphplaravelrestorelaravelrestorefilamentcreateMartinPetricko

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/martinpetricko-filament-restore-or-create/health.svg)

```
[![Health](https://phpackages.com/badges/martinpetricko-filament-restore-or-create/health.svg)](https://phpackages.com/packages/martinpetricko-filament-restore-or-create)
```

###  Alternatives

[relaticle/custom-fields

User Defined Custom Fields for Laravel Filament

15828.6k](/packages/relaticle-custom-fields)[jibaymcs/filament-tour

Bring the power of DriverJs to your Filament panels and start a tour !

12247.8k](/packages/jibaymcs-filament-tour)[guava/filament-modal-relation-managers

Allows you to embed relation managers inside filament modals.

7565.0k4](/packages/guava-filament-modal-relation-managers)[okeonline/filament-archivable

A filament plugin to use archivable models

208.1k](/packages/okeonline-filament-archivable)[tomatophp/filament-locations

Database Seeds for Countries / Cities / Areas / Languages / Currancy with ready to use resources for FilamentPHP

2320.8k6](/packages/tomatophp-filament-locations)[tapp/filament-webhook-client

Add a Filament resource and a policy for Spatie Webhook client

1120.2k](/packages/tapp-filament-webhook-client)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
