PHPackages                             createnl/expires - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. createnl/expires

ActiveLibrary[Database &amp; ORM](/categories/database)

createnl/expires
================

Set expiration date for database records, like future deleted at columns

0.3(8y ago)23.8kMITPHPPHP &gt;=7.1

Since Aug 1Pushed 8y ago1 watchersCompare

[ Source](https://github.com/createnl/expires)[ Packagist](https://packagist.org/packages/createnl/expires)[ Docs](https://github.com/Createnl/Expires)[ RSS](/packages/createnl-expires/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (3)Dependencies (4)Versions (4)Used By (0)

Expires
=======

[](#expires)

[![Latest Version on Packagist](https://camo.githubusercontent.com/fb24ab88ea420e454126eed0d2b1c720daf9e2ac9d208803268d9e8a4050d9af/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6372656174656e6c2f657870697265732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/createnl/expires)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/de4c75cd999275083786d33329ae1fc306387692f5f8624f7e7a8350b84c4ef6/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6372656174656e6c2f657870697265732f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/createnl/expires)[![Coverage Status](https://camo.githubusercontent.com/92b9d67fa87217230d19837fdddf9a64bf1ddac9204a0cd68743bdaef472e34c/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6372656174656e6c2f657870697265732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/createnl/expires/code-structure)[![Quality Score](https://camo.githubusercontent.com/ac0a76fab2f03a067200503eeba59d271cac6368abb396ebdad4f119ff54cf8c/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6372656174656e6c2f657870697265732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/createnl/expires)[![Total Downloads](https://camo.githubusercontent.com/0eb5bd29e55690f8b4bbcdf34e040122e18c55999950572ba155539bcefb66a5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6372656174656e6c2f657870697265732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/createnl/expires)

A package to add expiration date to database records.

Install
-------

[](#install)

### Via Composer

[](#via-composer)

```
$ composer require createnl/expires
```

Usage
-----

[](#usage)

### Your migration

[](#your-migration)

```
$table->dateTime('expires_at')->nullable()->default(null);
```

### Your model

[](#your-model)

```
class Model extends Eloquent
{
    use Createnl\Expires\Expirable

    /**
     * Indicates if the model should set an auto expire
     *
     * @var bool
     */
    protected static $autoExpire = true;

    /**
     * Indicates if the model should reset the expiration date on model update
     *
     * @var bool
     */
    protected static $autoExtend = true;

    /**
     * The amount of interval to be added to the
     * Please see ISO_8601 durations for correct markups
     *
     * @var string (\DateInterval)
     */
    protected static $autoExpireDate = 'P5Y';
}
```

### Methods

[](#methods)

```
// Get records with expired
$model->withExpired() : Builder;

// Get only expired records
$model->onlyExpired() : Builder;

// Update expiration date
$model->setExpiration(Carbon $date) : Model;

// Remove expiration date
$model->unExpire() : Model;

// Check if record is expired
$model->isExpired() : bool;

// Get carbon object of expiration date
$model->expiresAt() :? Carbon;

// Extend expiration by defined interval
$model->extendExpiration() : Model;

// Disable automatic setting of expiration date
Model::disableExpiring() : void;

// Enable automatic setting of expiration date
Model::enableExpiring() : void;
```

### Custom expiration date logic

[](#custom-expiration-date-logic)

```
/**
 * @override
 * Get Carbon object of parsed expiration date.
 *
 * @return Carbon
 */
public function expirationDate() : Carbon
{
    // @todo: Manipulate expiration date
    $interval = new \DateInterval(self::$autoExpireDate);
    return $this->freshTimestamp()->add($interval);
}
```

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Alex Lisenkov](https://github.com/alexlisenkov)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

3

Last Release

3207d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e4e251bec7bb0afd126754a0ab69d0d1e92b4a581d935c6ccf4621a7a1559e91?d=identicon)[createnl](/maintainers/createnl)

---

Tags

laravelmodeleloquentExpiresCreatenlExpires atFuture softdelete

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/createnl-expires/health.svg)

```
[![Health](https://phpackages.com/badges/createnl-expires/health.svg)](https://phpackages.com/packages/createnl-expires)
```

###  Alternatives

[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k7.2M71](/packages/mongodb-laravel-mongodb)[spatie/eloquent-sortable

Sortable behaviour for eloquent models

1.5k22.9M268](/packages/spatie-eloquent-sortable)[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)[spiritix/lada-cache

A Redis based, automated and scalable database caching layer for Laravel

591444.8k2](/packages/spiritix-lada-cache)[pdphilip/elasticsearch

An Elasticsearch implementation of Laravel's Eloquent ORM

145360.2k4](/packages/pdphilip-elasticsearch)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
