File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change 4
4
5
5
use Illuminate \Console \Command ;
6
6
use Illuminate \Support \Facades \File ;
7
- use Symfony \Component \Finder \SplFileInfo ;
7
+ use Illuminate \Support \Facades \Log ;
8
+ use Illuminate \Support \Facades \Storage ;
9
+ use Illuminate \Support \Str ;
8
10
9
11
class DataTablesPurgeExportCommand extends Command
10
12
{
@@ -29,13 +31,14 @@ class DataTablesPurgeExportCommand extends Command
29
31
*/
30
32
public function handle ()
31
33
{
32
- $ exportPath = config ('datatables-export.path ' , storage_path ( ' app/exports ' ) );
34
+ $ disk = config ('datatables-export.disk ' , ' local ' );
33
35
$ timestamp = now ()->subDay (config ('datatables-export.purge.days ' ))->getTimestamp ();
34
36
35
- collect (File::allFiles ($ exportPath ))
36
- ->each (function (SplFileInfo $ file ) use ($ timestamp ) {
37
- if ($ file ->getMTime () < $ timestamp && in_array (strtolower ($ file ->getExtension ()), ['xlsx ' , 'csv ' ])) {
38
- File::delete ($ file ->getRealPath ());
37
+ collect (Storage::disk ($ disk )->files ())
38
+ ->each (function ($ file ) use ($ timestamp , $ disk ) {
39
+ $ path = Storage::disk ($ disk )->path ($ file );
40
+ if (File::lastModified ($ path ) < $ timestamp && Str::endsWith (strtolower ($ file ), ['xlsx ' , 'csv ' ])) {
41
+ File::delete ($ path );
39
42
}
40
43
});
41
44
You can’t perform that action at this time.
0 commit comments