first commit
Some checks failed
Build / run (push) Has been cancelled

This commit is contained in:
maher
2025-10-29 11:42:25 +01:00
commit 703f50a09d
4595 changed files with 385164 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
<?php
namespace Common\Csv;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Storage;
class DeleteExpiredCsvExports extends Command
{
protected $signature = 'csvExports:delete';
protected $description = 'Deleted csv exports that are expired.';
public function handle(): int
{
$count = 0;
CsvExport::where(
'created_at',
'<',
Carbon::now()->addDays(-1),
)->chunkById(10, function (Collection $chunk) use ($count) {
$count += $chunk->count();
CsvExport::whereIn('id', $chunk->pluck('id'))->delete();
$filePaths = $chunk->map(function (CsvExport $export) {
return $export->filePath();
});
Storage::delete($filePaths);
});
$this->info("Deleted $count expired csv exports");
return Command::SUCCESS;
}
}