mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-19 00:22:15 +00:00
controller refactoring part 19
This commit is contained in:
27
src/Support/Scheduler/Actions/DeleteOldZipsAction.php
Normal file
27
src/Support/Scheduler/Actions/DeleteOldZipsAction.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Support\Scheduler\Actions;
|
||||
|
||||
|
||||
use Domain\Zipping\Models\Zip;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class DeleteOldZipsAction
|
||||
{
|
||||
/**
|
||||
* Delete old zips
|
||||
*/
|
||||
public function __invoke(): void
|
||||
{
|
||||
Zip::where('created_at', '<=', now()->subDay()->toDateTimeString())
|
||||
->get()
|
||||
->each(function ($zip) {
|
||||
// Delete zip file
|
||||
Storage::disk('local')->delete("zip/$zip->basename");
|
||||
|
||||
// Delete zip record
|
||||
$zip->delete();
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user