44 lines
1.0 KiB
PHP
44 lines
1.0 KiB
PHP
<?php
|
|
|
|
/*
|
|
* AVSDev UF Tweaks (https://avsdev.uk)
|
|
*
|
|
* @link https://git.avsdev.uk/avsdev/sprinkle-uf-tweaks
|
|
* @license https://git.avsdev.uk/avsdev/sprinkle-uf-tweaks/blob/master/LICENSE.md (LGPL-3.0 License)
|
|
*/
|
|
|
|
namespace UserFrosting\Sprinkle\UFTweaks\Scheduler\Tasks;
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Database\Capsule\Manager as Capsule;
|
|
use UserFrosting\Sprinkle\Scheduler\Scheduler\BaseTask;
|
|
use UserFrosting\Sprinkle\Core\Database\Models\Session;
|
|
|
|
|
|
/**
|
|
* Daily task to clean expired sessions from the database
|
|
*
|
|
* @author Craig Williams (https://avsdev.uk)
|
|
*/
|
|
class CleanupSessions extends BaseTask
|
|
{
|
|
/**
|
|
* Function used to specify the schedule for the task.
|
|
*/
|
|
public function schedule()
|
|
{
|
|
$this->daily()->at("23:00");
|
|
}
|
|
|
|
/**
|
|
* Function used to specify what the task does.
|
|
*/
|
|
public function run()
|
|
{
|
|
// Remove sessions over 2 days old
|
|
Session::where('last_activity', '<', time()-(60*60*48))->delete();
|
|
|
|
return true;
|
|
}
|
|
}
|