This commit is contained in:
salam committed 2026-04-21 14:46:58 +02:00
1 parent 4fa4e1a611
commit e46bda0715
10 files changed
+291 -221

No files matched your search

@@ -0,0 +1,37 @@
<?php
namespace App\Console\Commands;
use App\Models\StatistikoImport;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Storage;
class DeleteUnusedFiles extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'delete:unused-files';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Delete unused statistiko files';
/**
* Execute the console command.
*/
public function handle(): void
{
$tasks = StatistikoImport::pluck('file_name')->toArray();
collect(Storage::disk('public')->allFiles('statistiko'))
->reject(fn (string $file) => $file === '.gitignore')
->reject(fn (string $file) => in_array($file, $tasks))
->each(fn ($file) => Storage::disk('public')->delete($file));
}
}
+3
View File
@@ -12,7 +12,10 @@ class Kernel extends ConsoleKernel
*/
protected function schedule(Schedule $schedule): void
{
$schedule->command('delete:unused-files')->daily();
$schedule->command('model:prune')->daily();
// $schedule->command('inspire')->hourly();
}