Installation:
composer require promethys/revive
Publish the config and migrations:
php artisan vendor:publish --provider="Promethys\Revive\ReviveServiceProvider"
php artisan migrate
Register the Plugin:
Add to app/Providers/Filament/AdminPanelProvider.php:
public function panel(Panel $panel): Panel
{
return $panel
->plugins([
\Promethys\Revive\RevivePlugin::make(),
]);
}
First Use Case:
User::find(1)->delete())./admin/recycle-bin).Model Integration:
SoftDeletes trait.config/revive.php:
'query_scope' => \App\Models\Scopes\RecycleBinScope::class,
RevivePlugin::make():
RevivePlugin::make()
->columns([
Tables\Columns\TextColumn::make('custom_field'),
]),
Bulk Actions:
RevivePlugin::make()->actions([]).Search & Filtering:
RevivePlugin::make()
->query(function (Builder $query) {
return $query->where('deleted_at', '>', now()->subDays(7));
}),
Permissions:
canAccessRecycleBin policy:
public function canAccessRecycleBin(): bool
{
return auth()->user()->isAdmin();
}
Notifications:
ReviveEvents::MODEL_RESTORED) to send notifications:
ReviveEvents::MODEL_RESTORED->listen(function ($model) {
notify(new ModelRestored($model));
});
Migration Conflicts:
deleted_at already exists in your models, the package’s migration will fail. Skip it or manually add the column:
php artisan vendor:publish --tag="revive-migrations" --force
Query Scope Overrides:
\Promethys\Revive\Scopes\RecycleBinScope) may conflict with existing scopes. Use withoutGlobalScopes() if needed:
RevivePlugin::make()
->query(function (Builder $query) {
return $query->withoutGlobalScopes()->whereMorph('model_type', [User::class]);
}),
Performance:
RevivePlugin::make()
->perPage(20),
Soft-Deletes Timestamps:
deleted_at is nullable and indexed in your database:
$table->timestamp('deleted_at')->nullable()->index();
config/filament.php:
'debug' => env('FILAMENT_DEBUG', true),
php artisan event:listen ReviveEvents::MODEL_RESTORED
Custom Actions:
RevivePlugin::make()
->actions([
Tables\Actions\Action::make('preview')
->url(fn ($record) => route('admin.models.preview', $record))
->icon('heroicon-o-eye'),
]),
Dynamic Models:
ReviveServiceProvider::macro('registerModels', function (array $models) {
$this->app->make(\Promethys\Revive\ReviveServiceProvider::class)->registerModels($models);
});
Localization:
resources/lang/vendor/revive:
'restore' => 'Recuperar',
Testing:
ReviveTestCase trait for testing:
use Promethys\Revive\Testing\ReviveTestCase;
class RecycleBinTest extends ReviveTestCase
{
// ...
}
How can I help you explore Laravel packages today?