2017 © Pedro Peláez
 

library expires

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

image

createnl/expires

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

  • Thursday, August 3, 2017
  • by createnl
  • Repository
  • 1 Watchers
  • 0 Stars
  • 321 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 5 % Grown

The README.md

Expires

Latest Version on Packagist ![Software License][ico-license] Build Status ![Coverage Status][ico-scrutinizer] Quality Score ![Total Downloads][ico-downloads], (*1)

A package to add expiration date to database records., (*2)

Install

Via Composer

``` bash $ composer require createnl/expires, (*3)


## Usage ### Your migration ``` php $table->dateTime('expires_at')->nullable()->default(null);

Your model

``` php, (*4)

class Model extends Eloquent { use Createnl\Expires\Expirable, (*5)

/**
 * 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';

}, (*6)


### Methods ``` php // 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

``` php, (*7)

/** * @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); }, (*8)


## Change log Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. ## Testing ``` bash $ composer test

Contributing

Please see CONTRIBUTING and CONDUCT for details., (*9)

Security

If you discover any security related issues, please email alex@create.nl instead of using the issue tracker., (*10)

Credits

License

The MIT License (MIT). Please see License File for more information., (*11)

The Versions

03/08 2017

dev-master

9999999-dev https://github.com/Createnl/Expires

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

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel eloquent model createnl expires expires at future softdelete

03/08 2017

0.3

0.3.0.0 https://github.com/Createnl/Expires

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

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel eloquent model createnl expires expires at future softdelete

01/08 2017

0.2

0.2.0.0 https://github.com/Createnl/Expires

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

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel eloquent model createnl expires expires at future softdelete

01/08 2017

0.1

0.1.0.0 https://github.com/Createnl/Expires

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

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel eloquent model createnl expires expires at future softdelete