›
byrcsc/laravel-hold · 1.x
Announce expired holds and prune old history through Artisan.
| Command | What it does |
|---|---|
hold:expire | Stamp passed expiries and fire HoldExpired |
hold:prune [--days=] | Delete holds that died before the cutoff |
Both are optional. Availability is correct with neither ever running:
hold:expire only announces what the clock has already done, and hold:prune
only bounds history. The package registers no schedule for either.
php artisan hold:expireNo arguments and no options.
Expired 3 holds.Stamps expired_at on every hold that is unreleased, unstamped, and past its
expiry, and fires one HoldExpired event for each. The count is of holds this
run claimed, so a second run over the same table reports Expired 0 holds.
Always exits zero, including when there is nothing to stamp.
Walks the table in chunks of 500 by primary key, reading the clock once for the whole run. Overlapping runs are safe: the stamp is a conditional update, so exactly one run announces each hold.
Details in scheduling expiry.
php artisan hold:prune
php artisan hold:prune --days=90
php artisan hold:prune --days=0| Option | Effect |
|---|---|
--days= | Days of dead holds to keep. Defaults to 30 |
Pruned 412 holds.Deletes holds released, or expired, more than --days days ago. Active and
indefinite holds are never deleted, whatever the window. Fires no events.
Exits zero on success. Exits non-zero, deleting nothing, when --days is not a
whole number of days at least zero:
The --days option must be a whole number of days, zero or more.That covers negative numbers, decimals, and non-numeric strings. A negative window would put the cutoff in the future, where live holds are.
Deletes in passes of 500 keys until a pass removes nothing.
Details in pruning history.
use Illuminate\Support\Facades\Schedule;
Schedule::command('hold:expire')->everyMinute();
Schedule::command('hold:prune --days=90')->dailyAt('03:00');Schedule hold:expire only if something listens for HoldExpired. Choose the
hold:prune window from your retention policy.
The package also ships two publish tags, used once at install time:
php artisan vendor:publish --tag="hold-config"
php artisan vendor:publish --tag="hold-migrations"hold-config writes config/hold.php. hold-migrations writes the
create_holds_table migration into your application, timestamped at publish
time. See installation and setup.
hold:expire guarantees
and what it does not.