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(3mo ago)113.4k↓39.1%4[2 PRs](https://github.com/MartinPetricko/filament-restore-or-create/pulls)MITPHPPHP ^8.2CI passing

Since Apr 23Pushed 1w 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 3d ago

READMEChangelog (3)Dependencies (18)Versions (10)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

51

—

FairBetter than 95% of packages

Maintenance90

Actively maintained with recent releases

Popularity31

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity56

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

101d ago

Major Versions

1.x-dev → 2.0.02025-06-19

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/39132866?v=4)[Martin Petričko](/maintainers/MartinPetricko)[@MartinPetricko](https://github.com/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

[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)[relaticle/custom-fields

User Defined Custom Fields for Laravel Filament

16354.2k](/packages/relaticle-custom-fields)[stephenjude/filament-jetstream

A Laravel starter kit built with Filament inspired by Jetstream.

17760.2k3](/packages/stephenjude-filament-jetstream)[stephenjude/filament-two-factor-authentication

Filament Two Factor Authentication: Google 2FA + Passkey Authentication

84215.9k9](/packages/stephenjude-filament-two-factor-authentication)[croustibat/filament-jobs-monitor

Background Jobs monitoring like Horizon for all drivers for FilamentPHP

274327.2k9](/packages/croustibat-filament-jobs-monitor)[marcelweidum/filament-passkeys

Use passkeys in your filamentphp app

6649.5k1](/packages/marcelweidum-filament-passkeys)

PHPackages © 2026

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