{"id":19317213,"url":"https://github.com/createnl/expires","last_synced_at":"2026-05-16T04:33:27.842Z","repository":{"id":56958890,"uuid":"98991516","full_name":"createnl/expires","owner":"createnl","description":"Laravel eloquent expiration package","archived":false,"fork":false,"pushed_at":"2017-08-03T09:05:46.000Z","size":13,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-06T04:13:41.342Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/createnl.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-01T10:56:39.000Z","updated_at":"2018-12-20T12:49:42.000Z","dependencies_parsed_at":"2022-08-21T05:10:25.847Z","dependency_job_id":null,"html_url":"https://github.com/createnl/expires","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/createnl%2Fexpires","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/createnl%2Fexpires/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/createnl%2Fexpires/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/createnl%2Fexpires/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/createnl","download_url":"https://codeload.github.com/createnl/expires/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240420940,"owners_count":19798501,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T01:14:14.129Z","updated_at":"2026-05-16T04:33:27.801Z","avatar_url":"https://github.com/createnl.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Expires\n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Software License][ico-license]](LICENSE.md)\n[![Build Status][ico-travis]][link-travis]\n[![Coverage Status][ico-scrutinizer]][link-scrutinizer]\n[![Quality Score][ico-code-quality]][link-code-quality]\n[![Total Downloads][ico-downloads]][link-downloads]\n\nA package to add expiration date to database records.\n\n## Install\n\n### Via Composer\n\n``` bash\n$ composer require createnl/expires\n```\n\n## Usage\n\n### Your migration\n``` php\n\n$table-\u003edateTime('expires_at')-\u003enullable()-\u003edefault(null);\n\n```\n\n### Your model\n\n``` php\n\nclass Model extends Eloquent\n{\n    use Createnl\\Expires\\Expirable\n    \n    /**\n     * Indicates if the model should set an auto expire\n     *\n     * @var bool\n     */\n    protected static $autoExpire = true;\n     \n    /**\n     * Indicates if the model should reset the expiration date on model update\n     *\n     * @var bool\n     */\n    protected static $autoExtend = true;\n    \n    /**\n     * The amount of interval to be added to the\n     * Please see ISO_8601 durations for correct markups\n     *\n     * @var string (\\DateInterval)\n     */\n    protected static $autoExpireDate = 'P5Y';\n}\n```\n\n### Methods\n\n``` php\n\n// Get records with expired\n$model-\u003ewithExpired() : Builder;\n \n// Get only expired records\n$model-\u003eonlyExpired() : Builder;\n \n// Update expiration date\n$model-\u003esetExpiration(Carbon $date) : Model;\n \n// Remove expiration date\n$model-\u003eunExpire() : Model;\n \n// Check if record is expired\n$model-\u003eisExpired() : bool;\n \n// Get carbon object of expiration date\n$model-\u003eexpiresAt() :? Carbon;\n \n// Extend expiration by defined interval\n$model-\u003eextendExpiration() : Model;\n \n// Disable automatic setting of expiration date\nModel::disableExpiring() : void;\n \n// Enable automatic setting of expiration date\nModel::enableExpiring() : void;\n\n```\n\n### Custom expiration date logic\n\n``` php\n\n/**\n * @override\n * Get Carbon object of parsed expiration date.\n *\n * @return Carbon\n */\npublic function expirationDate() : Carbon\n{\n    // @todo: Manipulate expiration date\n    $interval = new \\DateInterval(self::$autoExpireDate);\n    return $this-\u003efreshTimestamp()-\u003eadd($interval);\n}\n\n```\n\n## Change log\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Testing\n\n``` bash\n$ composer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.\n\n## Security\n\nIf you discover any security related issues, please email alex@create.nl instead of using the issue tracker.\n\n## Credits\n\n- [Alex Lisenkov][link-author]\n- [All Contributors][link-contributors]\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n[ico-version]: https://img.shields.io/packagist/v/createnl/expires.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-travis]: https://img.shields.io/travis/createnl/expires/master.svg?style=flat-square\n[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/createnl/expires.svg?style=flat-square\n[ico-code-quality]: https://img.shields.io/scrutinizer/g/createnl/expires.svg?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/createnl/expires.svg?style=flat-square\n\n[link-packagist]: https://packagist.org/packages/createnl/expires\n[link-travis]: https://travis-ci.org/createnl/expires\n[link-scrutinizer]: https://scrutinizer-ci.com/g/createnl/expires/code-structure\n[link-code-quality]: https://scrutinizer-ci.com/g/createnl/expires\n[link-downloads]: https://packagist.org/packages/createnl/expires\n[link-author]: https://github.com/alexlisenkov\n[link-contributors]: ../../contributors\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcreatenl%2Fexpires","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcreatenl%2Fexpires","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcreatenl%2Fexpires/lists"}