added a help system, replaced the words "tenant" and "Pwa" with better alternatives. corrected and implemented cron jobs. prepared going live on a coolify-powered system.
This commit is contained in:
42
app/Console/Commands/DeactivateExpiredPhotoboothAccounts.php
Normal file
42
app/Console/Commands/DeactivateExpiredPhotoboothAccounts.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Event;
|
||||
use App\Services\Photobooth\PhotoboothProvisioner;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class DeactivateExpiredPhotoboothAccounts extends Command
|
||||
{
|
||||
protected $signature = 'photobooth:cleanup-expired';
|
||||
|
||||
protected $description = 'Disable Photobooth FTP accounts that have passed their expiry date.';
|
||||
|
||||
public function handle(PhotoboothProvisioner $provisioner): int
|
||||
{
|
||||
$total = 0;
|
||||
|
||||
Event::query()
|
||||
->where('photobooth_enabled', true)
|
||||
->whereNotNull('photobooth_expires_at')
|
||||
->where('photobooth_expires_at', '<=', now())
|
||||
->chunkById(50, function ($events) use (&$total, $provisioner) {
|
||||
foreach ($events as $event) {
|
||||
try {
|
||||
$provisioner->disable($event);
|
||||
$total++;
|
||||
} catch (\Throwable $exception) {
|
||||
Log::error('Failed to disable expired photobooth account', [
|
||||
'event_id' => $event->id,
|
||||
'message' => $exception->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$this->info(sprintf('Photobooth cleanup complete (%d accounts disabled).', $total));
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user