New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

andresuntoro/softexpires

A trait package to add soft expires feature to eloquent laravel/lumen
399

Larablocks Analysis

andresuntoro/softexpires works with Laravel 6, 7 and 8 (latest release v1.1, Jan 13, 2022), all past end of life (the last on Jan 24, 2023): no more fixes, even for security.

Recommendation checks

Not advised

Not advised: no release or commit in over 2 years.

  • No release or commit in over 2 years
  • Supports only Laravel 6, 7 and 8, past end of life since Jan 24, 2023
  • No release in the last 12 months (last: Jan 13, 2022)
  • 2 downloads a month (needs 10,000)
  • 0 GitHub stars (needs 100)

State

Likely abandoned
  • No release or commit in over 2 years.
  • Last stable release: Jan 13, 2022.
  • No releases in the last 12 months.
  • First released: Sep 30, 2021.
  • Monthly downloads: 2, down 82% from six months ago.
  • 0 open issues on GitHub.

Data from Packagist and GitHub, checked by Larablocks on Dec 1, 2026.

Install
composer require andresuntoro/softexpires
Latest Version:v1.1
PHP:^7.2.5 || ^8.0
Laravel:6 · 7 · 8
License:MIT
Last Updated:Jan 13, 2022
Links: GitHub  ·  Packagist
Maintainer: andresuntoro

SoftExpires

A simple trait package for eloquent laravel/lumen which is useful for handling expired data automatically.

Installation

Require this package, with Composer, in the root directory of your project. Composer 2 is a must!.

composer require andresuntoro/softexpires

Configuration

You should add the "expired_at" column to your database table.

Usage

Here you can see an example of you may use this package. Just add AndreSuntoro\Database\Eloquent\SoftExpires; to your model and use it. You can combine with others trait too, for the example: SoftDeletes.

<?php
namespace App\Models;

use AndreSuntoro\Database\Eloquent\SoftExpires;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Transaction extends Model {
    use SoftDeletes, SoftExpires;

    // ..

}

You can define when the data is considered expired. The data will not appear from the query results if it has reached the specified time limit, the default is 300 seconds(5 Mins).

<?php
namespace App\Models;

use AndreSuntoro\Database\Eloquent\SoftExpires;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Transaction extends Model {
    use SoftDeletes, SoftExpires;

    // in seconds, example 600 seconds (10 mins). The default is 300 seconds if not specified.
    const EXPIRED_AT_VALUE = 600; 

}

You can define your custom expired column if you don't use the default (expired_at).

<?php
namespace App\Models;

use AndreSuntoro\Database\Eloquent\SoftExpires;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Transaction extends Model {
    use SoftDeletes, SoftExpires;

    const EXPIRED_AT = 'my_expired_at';

}

Here you can see examples of using the available methods.

use App\Models\Transaction;

// As noted above, soft expired models will automatically be excluded from query results. However, you may force soft expired models to be included in a query's results by calling the withExpired method on the query:
$trx = Transaction::withExpired()->get();

// The onlyExpired method will retrieve only soft deleted models:
$trx = Transaction::onlyExpired()->get();

// To restore a soft expired model, you may call the reset method on a model instance. The restore method will set the model's expired_at column to null or your specified datetime:
$trx = Transaction::find(1);
$trx->reset(); // Set to null
$trx->reset(date('Y-m-d H:i:s')); // Set to your desired date time value


Related Packages

chiragardeshna/dbextender

It extends laravel default Query builder and Eloquent.

10 0
mrjgreen/database

Expressive Database Layer for PHP - Based on Illuminate/Database

48,876 52
laravel/database

Get Laravel database for your non laravel projects. Built on top of illuminate/d...

36,610 90
shiftonelabs/laravel-db-events

Add extra database events.

9,322 2
xabou/sql-dumper

Laravel SQL Queries Dumper

876 1

Version History

Version Released PHP Laravel License
v1.1 ^7.2.5 || ^8.0 ^6.0 || ^7.0 || ^8.0 MIT
v1.0 ^7.2.5 || ^8.0 ^6.0 || ^7.0 || ^8.0 MIT