| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- namespace App\Jobs;
- use App\Events\SendWebSocketMessageEvent;
- use App\Services\ExportMafService;
- use App\Services\ExportService;
- use Exception;
- use Illuminate\Contracts\Queue\ShouldQueue;
- use Illuminate\Foundation\Queue\Queueable;
- use Illuminate\Support\Facades\Log;
- class ExportMafJob implements ShouldQueue
- {
- use Queueable;
- /**
- * Create a new job instance.
- */
- public function __construct(
- private readonly int $userId,
- private readonly array $filters
- )
- {}
- /**
- * Execute the job.
- */
- public function handle(): void
- {
- try {
- $file = (new ExportMafService())->handle($this->userId);
- Log::info('ExportMaf job done!');
- Log::info($file);
- event(new SendWebSocketMessageEvent('Экспорт завершён!', $this->userId, ['download' => $file]));
- } catch (Exception $e) {
- Log::info('ExportCatalog job failed!');
- event(new SendWebSocketMessageEvent('Ошибка экспорта! ' . $e->getMessage(), $this->userId, ['error' => $e->getMessage()]));
- }
- }
- }
|