Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/WalletBalances.php
Show All 15 Lines | class WalletBalances extends Command | ||||
/** | /** | ||||
* The console command description. | * The console command description. | ||||
* | * | ||||
* @var string | * @var string | ||||
*/ | */ | ||||
protected $description = 'Show the balance on wallets'; | protected $description = 'Show the balance on wallets'; | ||||
/** | /** | ||||
* Create a new command instance. | |||||
* | |||||
* @return void | |||||
*/ | |||||
public function __construct() | |||||
{ | |||||
parent::__construct(); | |||||
} | |||||
/** | |||||
* Execute the console command. | * Execute the console command. | ||||
* | * | ||||
* @return mixed | * @return mixed | ||||
*/ | */ | ||||
public function handle() | public function handle() | ||||
{ | { | ||||
\App\Wallet::all()->each( | $wallets = \App\Wallet::select('wallets.*') | ||||
->join('users', 'users.id', '=', 'wallets.user_id') | |||||
->withEnvTenant('users') | |||||
->all(); | |||||
$wallets->each( | |||||
function ($wallet) { | function ($wallet) { | ||||
if ($wallet->balance == 0) { | if ($wallet->balance == 0) { | ||||
return; | return; | ||||
} | } | ||||
$user = \App\User::where('id', $wallet->user_id)->first(); | $user = $wallet->owner; | ||||
if (!$user) { | if (!$user) { | ||||
return; | return; | ||||
} | } | ||||
$this->info( | $this->info( | ||||
sprintf( | sprintf( | ||||
"%s: %8s (account: %s/%s (%s))", | "%s: %8s (account: %s/%s (%s))", | ||||
Show All 11 Lines |