first&last

This commit is contained in:
sbb45
2026-03-20 15:47:17 +05:00
commit d6441abdd2
230 changed files with 20367 additions and 0 deletions
@@ -0,0 +1,39 @@
<?php
namespace App\Console\Commands;
use App\Models\ServiceRequest;
use App\Models\User;
use App\Services\NotificationService;
use Illuminate\Console\Command;
class CheckSlaRequestsCommand extends Command
{
protected $signature = 'requests:check-sla';
protected $description = 'Проверка SLA и отправка предупреждений по заявкам';
public function __construct(private readonly NotificationService $notificationService)
{
parent::__construct();
}
public function handle(): int
{
$managers = User::query()->whereIn('role', ['admin', 'manager'])->get();
ServiceRequest::query()
->with(['status', 'assignee'])
->open()
->whereNotNull('deadline_at')
->whereBetween('deadline_at', [now(), now()->addHour()])
->each(fn (ServiceRequest $request) => $this->notificationService->notifySlaWarning($request, $managers));
ServiceRequest::query()
->with(['status', 'assignee'])
->overdue()
->each(fn (ServiceRequest $request) => $this->notificationService->notifyOverdue($request, $managers));
return self::SUCCESS;
}
}