Passed
Push — master ( cabec1...df3ce6 )
by Бабичев
07:36 queued 11s
created

RefreshBalance::multiUpdate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 15
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 20
rs 9.7666
1
<?php
2
3
namespace Bavix\Wallet\Commands;
4
5
use Bavix\Wallet\Models\Wallet;
6
use Bavix\Wallet\Services\DbService;
7
use function config;
8
use Illuminate\Console\Command;
9
use Illuminate\Database\PostgresConnection;
10
use Illuminate\Database\Query\JoinClause;
11
use Illuminate\Database\SQLiteConnection;
12
13
/**
14
 * Class RefreshBalance.
15
 * @codeCoverageIgnore
16
 */
17
class RefreshBalance extends Command
18
{
19
    /**
20
     * The name and signature of the console command.
21
     *
22
     * @var string
23
     */
24
    protected $signature = 'wallet:refresh';
25
26
    /**
27
     * The console command description.
28
     *
29
     * @var string
30
     */
31
    protected $description = 'Recalculates all wallets';
32
33
    /**
34
     * @return void
35
     * @throws
36
     */
37
    public function handle(): void
38
    {
39
        app(DbService::class)->transaction(function () {
40
            Wallet::query()->each(static function (Wallet $wallet) {
41
                $wallet->refreshBalance();
42
            });
43
        });
44
    }
45
46
}
47