SendPushNotificationsTask.php 528 B

1234567891011121314151617181920212223
  1. <?php
  2. namespace App\Tasks;
  3. use App\Services\PushNotificationDispatcher;
  4. use Illuminate\Support\Facades\Log;
  5. use Throwable;
  6. class SendPushNotificationsTask
  7. {
  8. public function __construct(private PushNotificationDispatcher $dispatcher) {}
  9. public function __invoke(): void
  10. {
  11. try {
  12. $this->dispatcher->dispatch();
  13. } catch (Throwable $e) {
  14. Log::error('SendPushNotificationsTask failed: ' . $e->getMessage(), [
  15. 'exception' => $e,
  16. ]);
  17. }
  18. }
  19. }