Changeset View
Changeset View
Standalone View
Standalone View
src/app/Console/Commands/WalletBalances.php
Show All 31 Lines | class WalletBalances extends Command | ||||
/** | /** | ||||
* 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 |