Artisan commands
messages:prune permanently deletes messages older than a retention window:
php artisan messages:prune --days=30 # defaults to MESSAGES_PRUNE_DAYS
php artisan messages:prune --thread=42 # limit to one thread- --days — the cutoff in days, a whole number of at least 1; defaults to prune.days (MESSAGES_PRUNE_DAYS, 90). 0, -1, ten, 1.9 or a blank value exits with an error before anything is deleted.
- --thread — limit pruning to one thread id. An id that names no thread (soft-deleted ones count) exits with an error rather than pruning every thread.
- Prunes unsent (soft-deleted) messages too — it is a hard delete.
- Removes attachment files when media.cleanup_on_force_delete is on.
- Re-points each affected thread’s latest message, so the inbox never previews a pruned message.
The command reports how many messages it removed. It runs through MessagesManager::prune(), so Messages::fake() records a console or scheduled prune too. Schedule it like any other Artisan command to enforce retention. From code, Messages::prune(days: 30, thread: $thread) does the same and returns the count; a window below 1 day throws InvalidArgumentException before anything is deleted.
Configuration overview
php artisan about # includes a "Messages" sectionThe Messages section shows models, key type, publicity, roles, system messages, notifications, broadcasting, preview length, retention and attachment settings — the shape of the configuration only, never content.
Show your open-source love
This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.
More ways to support, including cryptoBy donating, you agree to our donation terms.
Want this built into your product?
We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.