| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- namespace App\Jobs;
- use App\Services\NotificationService;
- use Illuminate\Contracts\Queue\ShouldQueue;
- use Illuminate\Foundation\Queue\Queueable;
- use Throwable;
- class SendUserNotificationChannelJob implements ShouldQueue
- {
- use Queueable;
- public int $tries = 3;
- public int $backoff = 60;
- public function __construct(
- private readonly int $userNotificationId,
- private readonly string $channel,
- ) {}
- public function handle(NotificationService $notificationService): void
- {
- $notificationService->deliverChannel(
- $this->userNotificationId,
- $this->channel,
- $this->attempts(),
- );
- }
- public function failed(?Throwable $exception): void
- {
- app(NotificationService::class)->markDeadLetter(
- $this->userNotificationId,
- $this->channel,
- $this->attempts(),
- $exception?->getMessage(),
- );
- }
- }
|