PHP code example of yarob / laravel-expirable

1. Go to this page and download the library: Download yarob/laravel-expirable library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

yarob / laravel-expirable example snippets


'providers' => [
    // ...
    Yarob\LaravelExpirable\ServiceProvider::class,
];

use Yarob\LaravelExpirable\Expirable;

class User extends Model
{
    use Expirable;
    
    /**
     * The attributes that should be mutated to dates.
     *
     * @var array
     */
    protected $dates = [
        'expire_at'
    ];

}

$user = App\User::get();

foreach($users as $user) {
		if($user->hasExpired())
		{
			var_dump($user->timeToLive());
			$user->reviveExpired();
			
			var_dump($user->timeToLive());	
		}
		else
		{
		    $user->expire_at = \Carbon\Carbon::now()->addDay(-10);// you can add minus values
            $user->save();
                        
            var_dump($user->timeToLive());	
		}
	}

 $users = App\User::get();

$users = App\User::withHasExpiry()->get();

$users = App\User::onlyHasExpiry()->get();

$users = App\User::withoutHasExpiry()->get();

return [

	/**
	 * Revival Time in seconds used to extend life in expired models
	 */

	'User' => [
		'revival_time' => 24*60*60,
	]
];

return [
    'foo' => [
    		'revival_time' => 24*60*60,
    	],
];
shell
php artisan vendor:publish --provider="Yarob\LaravelExpirable\ServiceProvider"