Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/Wallet/BalancesCommand.php
- This file was moved from src/app/Console/Commands/WalletBalances.php.
<?php | <?php | ||||
namespace App\Console\Commands; | namespace App\Console\Commands\Wallet; | ||||
use Illuminate\Console\Command; | use Illuminate\Console\Command; | ||||
class WalletBalances extends Command | class BalancesCommand extends Command | ||||
{ | { | ||||
/** | /** | ||||
* The name and signature of the console command. | * The name and signature of the console command. | ||||
* | * | ||||
* @var string | * @var string | ||||
*/ | */ | ||||
protected $signature = 'wallet:balances'; | protected $signature = 'wallet:balances'; | ||||
Show All 9 Lines | class BalancesCommand extends Command | ||||
* | * | ||||
* @return mixed | * @return mixed | ||||
*/ | */ | ||||
public function handle() | public function handle() | ||||
{ | { | ||||
$wallets = \App\Wallet::select('wallets.*') | $wallets = \App\Wallet::select('wallets.*') | ||||
->join('users', 'users.id', '=', 'wallets.user_id') | ->join('users', 'users.id', '=', 'wallets.user_id') | ||||
->withEnvTenantContext('users') | ->withEnvTenantContext('users') | ||||
->all(); | ->where('balance', '!=', '0') | ||||
->whereNull('users.deleted_at') | |||||
->orderBy('balance'); | |||||
$wallets->each( | $wallets->each( | ||||
function ($wallet) { | function ($wallet) { | ||||
if ($wallet->balance == 0) { | |||||
return; | |||||
} | |||||
$user = $wallet->owner; | $user = $wallet->owner; | ||||
if (!$user) { | |||||
return; | |||||
} | |||||
$this->info( | $this->info( | ||||
sprintf( | sprintf( | ||||
"%s: %8s (account: %s/%s (%s))", | "%s: %8s (account: %s/%s (%s))", | ||||
$wallet->id, | $wallet->id, | ||||
$wallet->balance, | $wallet->balance, | ||||
"https://kolabnow.com/cockpit/admin/accounts/show", | "https://kolabnow.com/cockpit/admin/accounts/show", | ||||
$user->id, | $user->id, | ||||
$user->email | $user->email | ||||
) | ) | ||||
); | ); | ||||
} | } | ||||
); | ); | ||||
} | } | ||||
} | } |