<?php
use Illuminate\Support\Facades\{Artisan,Schedule}; use App\Services\BackupService; use App\Models\{WorkerDocument,User}; use App\Services\NotificationService;
Artisan::command('softsuite:backup',function(BackupService $b){$run=$b->run();$this->info('Backup completed: '.$run->filename);})->purpose('Create a compressed MySQL backup');
Schedule::command('softsuite:backup')->dailyAt('02:15')->withoutOverlapping();
Schedule::call(function(NotificationService $n){WorkerDocument::with('user')->whereNotNull('expires_on')->whereBetween('expires_on',[today(),today()->addDays(30)])->get()->each(fn($d)=>$n->send($d->user,'Document expiry reminder',$d->title.' expires on '.$d->expires_on->format('Y-m-d')));})->name('document-expiry-reminders')->dailyAt('09:00')->withoutOverlapping();
Schedule::command('queue:prune-batches --hours=48')->daily();