/
itp_practice
/
itp_backend
Обзор
Документация
Войти
/
itp_practice
/
itp_backend
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
master
app/Console/Commands/TestCommand.php
55 строк
2 KB
vivanenko
run taps
29 май 2025, 21:05
29 май 2025, 21:05
b91be9d
Код
Авторство
О чём код?
<?php namespace App\Console\Commands; use App\Models\Order; use App\Services\TapAppService; use Illuminate\Console\Command; use Illuminate\Support\Facades\Log; class TestCommand extends Command { protected $signature = 'dev:test {--order-id=}'; protected $description = 'Test command'; private ?Order $order = null; public function __construct( private readonly TapAppService $tapAppService ) { parent::__construct(); } public function handle(): void { $this->order = Order::findOrFail($this->option('order-id')); if ($this->order === null) { throw new \Exception('Order not found'); } Log::info('Starting tap apps initialization job', [ 'order_id' => $this->order->id, 'user_id' => $this->order->user_id, ]); try { // Делегируем инициализацию тапов в сервис $result = $this->tapAppService->initializeTapAppsForOrder($this->order); Log::info('Tap apps initialization job completed successfully', [ 'order_id' => $this->order->id, 'subscriptions_processed' => $result['subscriptions_processed'], 'taps_initialized' => count($result['initialized_taps']), ]); } catch (\Exception $e) { Log::error('StartTapAppsJob failed', [ 'order_id' => $this->order->id, 'error' => $e->getMessage(), 'trace' => $e->getTraceAsString(), ]); throw $e; } } }