Kernel.php
1 <?php 2 3 namespace App\Console; 4 5 use App\Enums\FrequencyVerificationEnum; 6 use App\Jobs\CertificationReportCheck; 7 use App\Jobs\CleanTempDirectories; 8 use App\Jobs\DismissedCorrectionRequest; 9 use App\Jobs\EvaluationRequestCheck; 10 use App\Jobs\GrypeSpdx; 11 use App\Jobs\ProcessCertificationRequestMailbox; 12 use App\Jobs\ProcessVulnerabilityMailbox; 13 use App\Jobs\TaskEndNotifier; 14 use App\Models\Scheduler; 15 use App\Models\Setting; 16 use App\Models\TOE; 17 use Illuminate\Console\Scheduling\Schedule; 18 use Illuminate\Foundation\Console\Kernel as ConsoleKernel; 19 use Illuminate\Support\Collection; 20 use Spatie\Backup\Commands\BackupCommand; 21 22 class Kernel extends ConsoleKernel 23 { 24 /** 25 * Define the application's command schedule. 26 * 27 * @return void 28 */ 29 protected function schedule(Schedule $schedule) 30 { 31 $schedule->job(new CleanTempDirectories)->dailyAt('00:00'); 32 $schedule->command(BackupCommand::class)->dailyAt('00:00'); 33 $schedule->job(new TaskEndNotifier)->dailyAt('00:00'); 34 $schedule->command('clean:tmp-folder')->hourly(); 35 36 $schedulers = Scheduler::all(); 37 foreach ($schedulers as $scheduler) { 38 $job = new DismissedCorrectionRequest($scheduler); 39 match ($scheduler->frequency_verification_rectify) { 40 FrequencyVerificationEnum::daily()->value => $schedule->job($job)->dailyAt($scheduler->time_verification_rectify), 41 FrequencyVerificationEnum::weekly()->value => $schedule->job($job)->weeklyOn($scheduler->day_verification_rectify, $scheduler->time_verification_rectify), 42 FrequencyVerificationEnum::monthly()->value => $schedule->job($job)->monthlyOn($scheduler->day_verification_rectify, $scheduler->time_verification_rectify), 43 default => null, 44 }; 45 46 $job = new EvaluationRequestCheck($scheduler); 47 match ($scheduler->frequency_evaluation_request_check) { 48 FrequencyVerificationEnum::daily()->value => $schedule->job($job)->dailyAt($scheduler->time_evaluation_request_check), 49 FrequencyVerificationEnum::weekly()->value => $schedule->job($job)->weeklyOn($scheduler->day_evaluation_request_check, $scheduler->time_evaluation_request_check), 50 FrequencyVerificationEnum::monthly()->value => $schedule->job($job)->monthlyOn($scheduler->day_evaluation_request_check, $scheduler->time_evaluation_request_check), 51 default => null, 52 }; 53 54 $job = new CertificationReportCheck($scheduler); 55 match ($scheduler->frequency_certification_report_check) { 56 FrequencyVerificationEnum::daily()->value => $schedule->job($job)->dailyAt($scheduler->time_certification_report_check), 57 FrequencyVerificationEnum::weekly()->value => $schedule->job($job)->weeklyOn($scheduler->day_certification_report_check, $scheduler->time_certification_report_check), 58 FrequencyVerificationEnum::monthly()->value => $schedule->job($job)->monthlyOn($scheduler->day_certification_report_check, $scheduler->time_certification_report_check), 59 default => null, 60 }; 61 } 62 } 63 64 /** 65 * Register the commands for the application. 66 * 67 * @return void 68 */ 69 protected function commands() 70 { 71 $this->load(__DIR__ . '/Commands'); 72 73 require base_path('routes/console.php'); 74 } 75 }