Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
QuotationsRetryFailed
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 2
12
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 handle
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2
3namespace App\Console\Commands;
4
5use App\Services\PresupuestosService;
6use Illuminate\Console\Command;
7use Illuminate\Support\Facades\Log;
8
9
10class QuotationsRetryFailed extends Command
11{
12    /**
13     * The name and signature of the console command.
14     *
15     * @var string
16     */
17    protected $signature = 'quotations:retry-failed {name?} {region?}';
18
19    /**
20     * The console command description.
21     *
22     * @var string
23     */
24    protected $description = 'Synchronizes budgets for that failed';
25
26    protected $presupuestoService;
27
28    /**
29     * @var mixed
30     */
31    private $presupuestosService;
32
33    /**
34     * Create a new command instance.
35     *
36     * @return void
37     */
38    public function __construct(PresupuestosService $presupuestosService)
39    {
40        parent::__construct();
41        $this->presupuestosService = $presupuestosService;
42    }
43
44    /**
45     * Execute the console command.
46     *
47     * @return int
48     */
49    public function handle()
50    {
51        $name = $this->argument('name') ?? "System";
52        $region = $this->argument('region') ?? null;
53        try {
54            $result = $this->presupuestosService->syncErrorBudgets($name, $region);
55            return Command::SUCCESS;
56        } catch (\Exception $e) {
57            Log::channel('g3w')->error("Synchronization of failed budgets failed, Error: " . $e->getMessage());
58            return Command::FAILURE;
59        }
60    }
61}