maize-tech/laravel-prunable-fields
Laravel Prunable Fields lets you mark model attributes as prunable and automatically clear or remove them after a configurable period, with minimal setup. A simple, flexible way to implement data retention policies and GDPR compliance in your Laravel apps.
composer require maize-tech/laravel-prunable-fields. On Laravel 11, require ^1.3 (1.3.0 adds Laravel 11 compatibility; no other changes are listed).use Maize\PrunableFields\Concerns\PrunableFields;.prunableFields()-style method returning field names or field => interval pairs). Check the README for the exact signature in your installed version.app/Console/Kernel.php or routes/console.php (Laravel 11), or run it manually once to confirm behavior.email, phone, or fiscal_code after the retention period instead of deleting the entire row.MassPrunable only when whole records should be deleted.email after 30 days, phone after 90). Otherwise split models or use multiple scheduled commands.created_at or updated_at).Carbon::setTestNow() / travel() to freeze time, create records just inside and outside the retention window, run the command, and assert that only eligible fields were nulled. Also assert that non-prunable fields and the row itself still exist.NULL, an empty string, or a redacted placeholder. If downstream code assumes non-null values, prefer a placeholder or update consumers first.updating/updated observers will not fire. If you depend on events to sync search indexes or audit logs, trigger that work explicitly after pruning.NULL. Nulling a unique column may be fine in MySQL/PostgreSQL (multiple NULLs allowed) but not in SQL Server. Check driver-specific behavior.created_at, not updated_at, if a later edit should not extend retention). Be explicit in the model declaration and tests.^1.3 only if you need Laravel 11.php artisan config:cache in deployment and clear it during debugging. Config changes will not take effect until the cache is rebuilt.routes/console.php rather than Kernel.php. Confirm the package command is registered and visible via php artisan list before scheduling it.How can I help you explore Laravel packages today?