controller refactoring part 19

This commit is contained in:
Peter Papp
2021-07-21 12:01:44 +02:00
parent 76e1cd1113
commit 3860faf851
10 changed files with 146 additions and 120 deletions
@@ -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();
}
});
}
}