1
0
mirror of https://github.com/freescout-helpdesk/freescout.git synced 2024-11-24 11:22:42 +01:00

Delete send logs older 6 months

This commit is contained in:
FreeScout 2020-12-21 07:04:11 -08:00
parent c6fa18fe8d
commit 40cebf61c2
2 changed files with 49 additions and 0 deletions

View File

@ -0,0 +1,46 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class CleanSendLog extends Command
{
const PERIOD = '-6 months';
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'freescout:clean-send-log';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Delete old records from send log.';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$logs = \App\SendLog::where('created_at', '<', \Carbon\Carbon::now()->modify(self::PERIOD))->delete();
$this->info('['.date('Y-m-d H:i:s').'] Deleted send logs: '.self::PERIOD);
}
}

View File

@ -54,6 +54,9 @@ class Kernel extends ConsoleKernel
->everyMinute()
->withoutOverlapping();
$schedule->command('freescout:clean-send-log')
->monthly();
// Logs monitoring.
$alert_logs_period = config('app.alert_logs_period');
if (config('app.alert_logs') && $alert_logs_period) {