Files
exchange-2.0/app/Console/Commands/DeleteBulkInvoiceFiles.php
2023-10-12 19:09:56 +08:00

45 lines
1.2 KiB
PHP

<?php
namespace App\Console\Commands;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\File;
class DeleteBulkInvoiceFiles extends Command
{
protected $signature = 'delete:bulk-download-files';
protected $description = 'Delete all the bulk download files';
public function __construct()
{
parent::__construct();
}
public function handle()
{
$directories = [
storage_path('app/bulk_invoice'),
storage_path('app/bulk_whiteform'),
];
foreach ($directories as $directory) {
$start = new Carbon();
$this->info(Carbon::now() . ' Start cleaning - ' . $directory);
if (File::isDirectory($directory)) {
File::cleanDirectory($directory);
$this->info('All files have been deleted.');
} else {
$this->info('Directory does not exist.');
}
$end = new Carbon();
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
$this->info(Carbon::now() . ' Process ended. ElapsedTime: ' . $elapsedTime);
}
}
}