createnl/expires
A Laravel package for adding expiration to Eloquent models. Attach expiry dates to records, automatically scope out or clean up expired entries, and keep outdated data under control with simple, configurable traits and queries.
composer require vendor/package. The 0.3 README is the first place to check for new install steps, config publishing, and migration notes.Model instead of bool. For example, call the method, inspect the returned model, and chain Eloquent operations directly:
$record = $package->someMethod($data);
if ($record !== null) {
$record->update(['processed_at' => now()]);
}
addOnlyExpired fix with a small test: create one expired and one active record, call addOnlyExpired, and assert only the expired record is added.bool now return a Model instance or null on failure. Use explicit null checks ($model = $package->method(); if ($model === null) { ... }) and inspect $model->wasRecentlyCreated or $model->exists when you need to distinguish creation from an existing record.$package->addSomething($data)->load('relation');
addOnlyExpired to avoid duplicating active entries. Pair it with scheduled commands or queued jobs that periodically refresh expired items. For example, a nightly job can call addOnlyExpired for each user or resource.bool to Model is breaking. Audit every call site. Replace strict checks like if ($result === true) with if ($result !== null) or if ($result). Update return type hints and docblocks on any wrapper methods. Code that returned the old bool directly from a function will now fail type checks.addOnlyExpired bug fix: If you had workarounds for the old bug, remove them. Test edge cases: expired vs. non-expired records, timezone handling, and concurrent calls. The fix may change which records are added, so verify existing data assumptions.Model return can be null on failure. Avoid treating null as false in strict comparisons. Use is_null() or !== null for clarity.dd($model) on the returned model to inspect attributes and existence state. If a method unexpectedly returns null, check the package’s logging or exception handling.How can I help you explore Laravel packages today?