ExportSparePartsJob.php 779 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace App\Jobs\Export;
  3. use App\Events\SendWebSocketMessageEvent;
  4. use App\Services\Export\ExportSparePartsService;
  5. use Illuminate\Contracts\Queue\ShouldQueue;
  6. use Illuminate\Foundation\Queue\Queueable;
  7. class ExportSparePartsJob implements ShouldQueue
  8. {
  9. use Queueable;
  10. /**
  11. * Create a new job instance.
  12. */
  13. public function __construct(private readonly int $userId)
  14. {
  15. }
  16. /**
  17. * Execute the job.
  18. */
  19. public function handle(ExportSparePartsService $service): void
  20. {
  21. $link = $service->handle($this->userId);
  22. event(new SendWebSocketMessageEvent(
  23. 'Экспорт каталога запчастей завершён!',
  24. $this->userId,
  25. ['link' => $link]
  26. ));
  27. }
  28. }