feat: Initialize core application structure including authentication, role-based dashboards, service task management, and integration workflows.
This commit is contained in:
36
app/Jobs/CheckSlaDeadlines.php
Normal file
36
app/Jobs/CheckSlaDeadlines.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\ServiceTask;
|
||||
use App\Enums\ServiceTaskStatus;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CheckSlaDeadlines implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$overdueTasks = ServiceTask::where('status', '!=', ServiceTaskStatus::Completed)
|
||||
->where('sla_deadline', '<', now())
|
||||
->with(['service', 'integrationRequest.agent'])
|
||||
->get();
|
||||
|
||||
foreach ($overdueTasks as $task) {
|
||||
// Log for audit
|
||||
Log::warning("SLA Overdue for task ID {$task->id} (Service: {$task->service->name})");
|
||||
|
||||
// Notify service members
|
||||
$serviceRole = $task->service->name;
|
||||
$users = \App\Models\User::role($serviceRole)->get();
|
||||
\Illuminate\Support\Facades\Notification::send($users, new \App\Notifications\SlaOverdueNotification($task));
|
||||
|
||||
// Also notify RH
|
||||
$rhUsers = \App\Models\User::role('RH')->get();
|
||||
\Illuminate\Support\Facades\Notification::send($rhUsers, new \App\Notifications\SlaOverdueNotification($task));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user