| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- namespace App\Jobs;
- use App\Events\SendWebSocketMessageEvent;
- use App\Services\ExportOrdersService;
- use App\Services\ExportScheduleService;
- use Exception;
- use Illuminate\Contracts\Queue\ShouldQueue;
- use Illuminate\Foundation\Queue\Queueable;
- use Illuminate\Support\Collection;
- use Illuminate\Support\Facades\Log;
- class ExportOrdersJob implements ShouldQueue
- {
- use Queueable;
- /**
- * Create a new job instance.
- */
- public function __construct(
- private readonly Collection $orders,
- private readonly int $userId,
- )
- {}
- /**
- * Execute the job.
- */
- public function handle(): void
- {
- try {
- $link = (new ExportOrdersService())->handle($this->orders, $this->userId);
- Log::info('Export orders finished!');
- event(new SendWebSocketMessageEvent('Экспорт площадок готов!', $this->userId, ['success' => true, 'link' => $link]));
- } catch (Exception $e) {
- Log::error('Export orders failed! ' . $e->getMessage());
- event(new SendWebSocketMessageEvent('Ошибка экспорта площадок! ', $this->userId, ['error' => $e->getMessage()]));
- }
- }
- }
|