added schedule for delete users older as 30 days

This commit is contained in:
Milos Holba
2021-05-22 13:12:03 +02:00
parent 0139cc92bf
commit fd7a23225c
4 changed files with 23 additions and 33 deletions

View File

@@ -3,6 +3,7 @@ namespace App\Services;
use Carbon\Carbon;
use App\Models\Zip;
use App\Models\User;
use App\Models\Share;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
@@ -74,4 +75,19 @@ class SchedulerService
}
});
}
/**
* Delete unverified users older as 30 days
*/
public function delete_unverified_users(): void
{
User::where('created_at', '<=', now()->subDay(30)->toDateString())
->where('email_verified_at', null)
->get()
->each(function ($user) {
// Delete users
$user->delete();
});
}
}