Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
SyncNuvemshopOrdersCommand
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 handle
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace App\Console\Commands;
4
5use App\Jobs\SyncNuvemshopOrdersJob;
6use App\Models\StoreIntegration;
7use Illuminate\Console\Command;
8
9class SyncNuvemshopOrdersCommand extends Command
10{
11    protected $signature = 'orvox:nuvemshop:sync-orders {--from=} {--to=}';
12    protected $description = 'Sincroniza pedidos da Nuvemshop para todas as integrações conectadas.';
13
14    public function handle(): int
15    {
16        StoreIntegration::query()
17            ->whereHas('provider', fn ($q) => $q->where('slug', 'nuvemshop'))
18            ->where('status', 'connected')
19            ->each(function (StoreIntegration $integration) {
20                SyncNuvemshopOrdersJob::dispatch($integration->id, $this->option('from'), $this->option('to'));
21                $this->info('Sincronização enviada: integração #'.$integration->id);
22            });
23
24        return self::SUCCESS;
25    }
26}