<?php
namespace App\Jobs;use App\Models\OperationsAlert;use Illuminate\Bus\Queueable;use Illuminate\Contracts\Queue\ShouldQueue;use Illuminate\Foundation\Bus\Dispatchable;use Illuminate\Queue\InteractsWithQueue;use Illuminate\Queue\SerializesModels;use Illuminate\Support\Facades\DB;
final class AuditAndFailedJobReportJob implements ShouldQueue {use Dispatchable,InteractsWithQueue,Queueable,SerializesModels;public function __construct(){$this->onQueue('notifications');}public function handle():void{$count=DB::table('failed_jobs')->where('failed_at','>=',now()->subDay())->count();if($count)OperationsAlert::create(['severity'=>'critical','code'=>'DAILY_FAILED_JOB_REPORT','message'=>"{$count} queue jobs failed in the last 24 hours.",'context'=>['failed_jobs'=>$count]]);}}
