Skip to content

Commit

Permalink
Remove old submission_confirmations
Browse files Browse the repository at this point in the history
  • Loading branch information
kreut committed Oct 14, 2024
1 parent b65a7d5 commit f98ebd1
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions app/Console/Commands/removeOldSubmissionConfirmations.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace App\Console\Commands;

use App\Exceptions\Handler;
use Carbon\Carbon;
use Exception;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;

class removeOldSubmissionConfirmations extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'remove:oldSubmissionConfirmations';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return int
* @throws Exception
*/
public function handle()
{
try {
$oneWeekAgo = Carbon::now()->subWeek();
DB::table('submission_confirmations')
->where('created_at', '<', $oneWeekAgo)
->delete();
} catch (Exception $e) {
echo $e->getMessage();
$h = new Handler(app());
$h->report($e);
return 1;
}
return 0;
}
}

0 comments on commit f98ebd1

Please sign in to comment.