. */ namespace App\Console\Commands\Accounts; use Illuminate\Console\Command; use Carbon\Carbon; use App\AccountTombstone; class ClearAccountsTombstones extends Command { protected $signature = 'accounts:clear-accounts-tombstones {days} {--apply}'; protected $description = 'Clear deleted accounts tombstones after n days'; public function handle() { $tombstones = AccountTombstone::where( 'created_at', '<', Carbon::now()->subDays($this->argument('days'))->toDateTimeString() ); if ($this->option('apply')) { $this->info($tombstones->count() . ' tombstones deleted'); $tombstones->delete(); return Command::SUCCESS; } $this->info($tombstones->count() . ' tombstones to delete'); return Command::SUCCESS; } }