Skip to content

Commit 29058fe

Browse files
committed
Update purge cmd to use the export path from config
1 parent c04fd9c commit 29058fe

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/Commands/DataTablesPurgeExportCommand.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
namespace Yajra\DataTables\Commands;
44

55
use Illuminate\Console\Command;
6-
use Illuminate\Support\Facades\Storage;
6+
use Illuminate\Support\Facades\File;
7+
use Symfony\Component\Finder\SplFileInfo;
78

89
class DataTablesPurgeExportCommand extends Command
910
{
@@ -28,10 +29,12 @@ class DataTablesPurgeExportCommand extends Command
2829
*/
2930
public function handle()
3031
{
31-
collect(Storage::listContents('exports'))
32-
->each(function ($file) {
33-
if ($file['timestamp'] < now()->subDay(config('datatables-export.purge.days'))->getTimestamp()) {
34-
Storage::delete($file['path']);
32+
$exportPath = config('datatables-export.path', storage_path('app/exports'));
33+
34+
collect(File::allFiles($exportPath))
35+
->each(function (SplFileInfo $file) {
36+
if ($file->getMTime() < now()->subDay(config('datatables-export.purge.days'))->getTimestamp()) {
37+
File::delete($file->getRealPath());
3538
}
3639
});
3740

0 commit comments

Comments
 (0)