Installation:
composer require promethys/revive
php artisan revive:install
Ensure you're using Laravel 11+, Filament v5, and PHP 8.2+.
Register the Plugin: Add to your Filament panel configuration:
use Promethys\Revive\RevivePlugin;
$panel->plugins([
RevivePlugin::make(),
]);
Enable Recycling for Models:
Add the Recyclable trait to any soft-deletable model:
use Promethys\Revive\Concerns\Recyclable;
class Post extends Model
{
use SoftDeletes;
use Recyclable;
}
Access the Recycle Bin: Navigate to the new "Recycle Bin" entry in your Filament sidebar.
Deletion:
$post->delete()).revive_records).Restoration:
restore() call and cleans up its tracking.Permanent Deletion:
RevivePlugin::make()
->models([Post::class, Comment::class])
public function boot()
{
$models = Model::where('is_recyclable', true)->get()->pluck('class');
$this->app->make(RevivePlugin::class)->models($models);
}
RevivePlugin::make()
->enableUserScoping()
RevivePlugin::make()
->enableTenantScoping()
RevivePlugin::make()
->showAllRecords()
->authorize(fn () => auth()->user()->isAdmin())
@livewire(\Promethys\Revive\Tables\RecycleBin::class, [
'models' => [App\Models\Post::class],
'user' => auth()->user(),
])
class CustomRecycleBin extends \Promethys\Revive\Tables\RecycleBin
{
protected function getTableColumns(): array
{
return [
...parent::getTableColumns(),
TextColumn::make('custom_field'),
];
}
}
php artisan revive:discover-soft-deleted --with-scope
Run this after upgrading or when migrating existing soft-deleted records.Missing SoftDeletes Trait:
Recyclable trait requires SoftDeletes.use Illuminate\Database\Eloquent\SoftDeletes;
use Promethys\Revive\Concerns\Recyclable;
class Post extends Model
{
use SoftDeletes, Recyclable;
}
Namespace Restrictions:
App\Models namespace by default.namespace App\Models;
use Promethys\Revive\Concerns\Recyclable;
use Vendor\Package\Models\ThirdPartyModel;
class ThirdPartyModelWrapper extends ThirdPartyModel
{
use SoftDeletes, Recyclable;
}
Scoping Conflicts:
enableUserScoping and enableTenantScoping can cause unexpected behavior.RevivePlugin::make()
->enableUserScoping()
->enableTenantScoping(false)
State Snapshots:
getAttributes() or explicitly define snapshot fields:
protected static function getReviveSnapshotAttributes(): array
{
return ['title', 'content', 'published_at'];
}
Check Tracking:
Verify records are being tracked in the revive_records table:
php artisan tinker
>>> \Promethys\Revive\Models\ReviveRecord::all();
Log Deletions: Enable logging for debugging:
RevivePlugin::make()
->logDeletions(true);
CLI Dry Runs: Test the discovery command without changes:
php artisan revive:discover-soft-deleted --dry-run
Large Datasets:
revive_records table:
Schema::table('revive_records', function (Blueprint $table) {
$table->index('model_type');
$table->index('model_id');
});
Snapshot Storage:
Custom Actions: Extend the table to add custom actions:
protected function getTableRecordActions(): array
{
return [
...parent::getTableRecordActions(),
Action::make('customAction')
->action(function (ReviveRecord $record) {
// Custom logic
}),
];
}
Override Restoration Logic: Hook into the restoration process:
use Promethys\Revive\Events\RecordRestored;
Event::listen(RecordRestored::class, function ($event) {
// Post-restore logic
});
Custom Scoping: Override the default scoping logic in your model:
class Post extends Model
{
use Recyclable;
public function scopeCustomScoping($query)
{
return $query->where('is_active', true);
}
}
How can I help you explore Laravel packages today?