mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-24 01:50:38 +00:00
controller refactoring part 19
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?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();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user