mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-23 01:32:15 +00:00
27 lines
650 B
PHP
27 lines
650 B
PHP
<?php
|
|
namespace Support\Scheduler\Actions;
|
|
|
|
use Carbon\Carbon;
|
|
use Domain\Sharing\Models\Share;
|
|
|
|
class DeleteExpiredShareLinksAction
|
|
{
|
|
/**
|
|
* Get and delete expired shared links
|
|
*/
|
|
public function __invoke(): void
|
|
{
|
|
Share::whereNotNull('expire_in')
|
|
->get()
|
|
->each(function ($share) {
|
|
// Get dates
|
|
$created_at = Carbon::parse($share->created_at);
|
|
|
|
// If time was over, then delete share record
|
|
if ($created_at->diffInHours(now()) >= $share->expire_in) {
|
|
$share->delete();
|
|
}
|
|
});
|
|
}
|
|
}
|