Restore or Create by Martin Petričko
CommunityRestore or Create is a plugin that helps prevent duplicate records by detecting and restoring soft-deleted models when similar data is submitted via a create form.
Author:
Martin Petričko
Package health
Automated checks of this plugin's Composer package
15 checks
- Failed: GitHub Actions pinned to SHA — View details on Plumb
- Skipped: GitLab CI includes pinned to SHA
- Passed: Open security advisories
- Failed: Dependabot PR responsiveness — Stale Dependabot PRs: oldest general PR is 181 days old. View details on Plumb
- Skipped: Renovate MR responsiveness
- Passed: Dependabot or Renovate configured
-
Failed:
Dependency update cooldown configured
—
No cooldown configured in
.github/dependabot.yml. View details on Plumb - Passed: Provides a security policy
- Passed: Abandoned or archived — No consulted source marks the package abandoned (packagist, github).
- Warning: Commit and release recency — Low activity: last commit 206 days ago; last release 206 days ago.
-
Passed:
composer.lock not committed by library
—
composer.lockis absent from the released dist archive. - Passed: Dist archive is lean
-
Passed:
Current Laravel version supported
—
Package dependencies resolve together with current Laravel
13.0. -
Passed:
Current PHP version supported
—
Constraint
^8.2supports current PHP8.5. - Skipped: Current Symfony version supported
filament/
namespace. Review the source and install at your own risk. Found
malware or an unresolved security issue the author won't
address?
Report it
.
Documentation
- Features
- Installation
- Usage
- Customization
- Advanced Integration
- Testing
- Contributing
- Security Vulnerabilities
- Credits
- License
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
- 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
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
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
#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
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
Choose which attributes to show in the confirmation modal:
protected function showDeletedAttributes(): ?array
{
return ['name', 'email', 'phone', 'address', 'deleted_at'];
}
#Restore Notification
Customize the notification shown after a record is restored:
protected function getRestoredNotification(): ?Notification
{
return Notification::make()
->success()
->title('Restored');
}
#Redirect After Restore
Control where the user is redirected after restoring:
protected function getRestoreRedirectUrl(Model $record): string
{
/** @var class-string<Resource> $resource */
$resource = static::getResource();
if ($resource::hasPage('edit') && $resource::canEdit($record)) {
return $resource::getUrl('edit', ['record' => $record]);
}
return $resource::getUrl();
}
#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
composer test
#Contributing
Please see CONTRIBUTING for details.
#Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
#Credits
#License
The MIT License (MIT). Please see License File for more information.
The author
I began my programming journey in elementary school as a hobby, which grew into a passion. Since then, I have consistently pursued growth and creating effective solutions. Specializing in back-end development, I prioritize writing clean, maintainable, and standards-compliant code.
From the same author
Sentry User Feedback
Sentry User Feedback integration.
Author:
Martin Petričko
Database Mail
Are you tired of writing email templates in laravel, managing all translations and editing them always when something changes? Well not anymore! Let your clients manage them in filament panel and call it a feature!
Author:
Martin Petričko
Featured Plugins
A selection of plugins curated by the Filament team
Soft Theme
A theme that gives panels a warm, approachable look with rounded shapes, gentle colors, and serif headings.
Filament
Sharp Theme
A theme that gives panels a precise, technical look with square corners, strong borders, and clear contrast.
Filament
Spotlight Pro
Browse your Filament Panel with ease. Filament Spotlight Pro adds a Spotlight like Command Palette to your Filament Panel.
Dennis Koch